From 1178f4865ba3d7e58d68de50dcb8073b098dcb37 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Wed, 5 Jun 2019 12:35:41 +0200 Subject: [PATCH] REFACTOR: login-method model (#7703) --- .../discourse/models/login-method.js.es6 | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/app/assets/javascripts/discourse/models/login-method.js.es6 b/app/assets/javascripts/discourse/models/login-method.js.es6 index 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({ @computed message() { - 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; }