A platform for community discussion. Free, open, simple.
REFACTOR: login-method model (#7703)
Joffrey JAFFEUX1178f4865ba3
diff --git a/app/assets/javascripts/discourse/models/login-method.js.es6 b/app/assets/javascripts/discourse/models/login-method.js.es6index f79644ee712..244e75b6259 100644--- a/app/assets/javascripts/discourse/models/login-method.js.es6+++ b/app/assets/javascripts/discourse/models/login-method.js.es6@@ -13,7 +13,7 @@ const LoginMethod = Ember.Object.extend({@computedmessage() {- return this.message_override || I18n.t("login." + this.name + ".message");+ return this.message_override || I18n.t(`login.${this.name}.message`);},doLogin({ reconnect = false, fullScreenLogin = true } = {}) {@@ -23,7 +23,7 @@ const LoginMethod = Ember.Object.extend({if (customLogin) {customLogin();} else {- let authUrl = this.custom_url || Discourse.getURL("/auth/" + name);+ let authUrl = this.custom_url || Discourse.getURL(`/auth/${name}`);if (reconnect) {authUrl += "?reconnect=true";@@ -45,7 +45,7 @@ const LoginMethod = Ember.Object.extend({authUrl += "display=popup";}- const w = window.open(+ const windowState = window.open(authUrl,"_blank","menubar=no,status=no,height=" +@@ -57,11 +57,11 @@ const LoginMethod = Ember.Object.extend({",top=" +top);- const self = this;- const timer = setInterval(function() {- if (!w || w.closed) {++ const timer = setInterval(() => {+ if (!windowState || windowState.closed) {clearInterval(timer);- self.set("authenticate", null);+ this.set("authenticate", null);}}, 1000);}@@ -72,18 +72,16 @@ const LoginMethod = Ember.Object.extend({let methods;export function findAll() {- if (methods) {- return methods;- }+ if (methods) return methods;methods = [];- Discourse.Site.currentProp("auth_providers").forEach(provider => {- methods.pushObject(LoginMethod.create(provider));- });+ Discourse.Site.currentProp("auth_providers").forEach(provider =>+ methods.pushObject(LoginMethod.create(provider))+ );// exclude FA icon for Google, uses custom SVG- methods.forEach(m => m.set("isGoogle", m.get("name") === "google_oauth2"));+ methods.forEach(m => m.set("isGoogle", m.name === "google_oauth2"));return methods;}