FEATURE: use full screen login by default for social login methods (#7481)

FEATURE: use full screen login by default for social login methods (#7481)

diff --git a/app/assets/javascripts/discourse.js.es6 b/app/assets/javascripts/discourse.js.es6
index 9d4b5d4..a05df2f 100644
--- a/app/assets/javascripts/discourse.js.es6
+++ b/app/assets/javascripts/discourse.js.es6
@@ -11,7 +11,6 @@ const Discourse = Ember.Application.extend({
   _docTitle: document.title,
   RAW_TEMPLATES: {},
   __widget_helpers: {},
-  useFullScreenLogin: false,
   customEvents: {
     paste: "paste"
   },
diff --git a/app/assets/javascripts/discourse/components/login-buttons.js.es6 b/app/assets/javascripts/discourse/components/login-buttons.js.es6
index 4f0697f..3279bda 100644
--- a/app/assets/javascripts/discourse/components/login-buttons.js.es6
+++ b/app/assets/javascripts/discourse/components/login-buttons.js.es6
@@ -12,11 +12,7 @@ export default Ember.Component.extend({
 
   @computed
   buttons() {
-    return findAll(
-      this.siteSettings,
-      this.capabilities,
-      this.site.isMobileDevice
-    );
+    return findAll();
   },
 
   actions: {
diff --git a/app/assets/javascripts/discourse/controllers/create-account.js.es6 b/app/assets/javascripts/discourse/controllers/create-account.js.es6
index 7b88f79..c75ed35 100644
--- a/app/assets/javascripts/discourse/controllers/create-account.js.es6
+++ b/app/assets/javascripts/discourse/controllers/create-account.js.es6
@@ -186,7 +186,7 @@ export default Ember.Controller.extend(
     // Determines whether at least one login button is enabled
     @computed
     hasAtLeastOneLoginButton() {
-      return findAll(this.siteSettings).length > 0;
+      return findAll().length > 0;
     },
 
     @on("init")
diff --git a/app/assets/javascripts/discourse/controllers/invites-show.js.es6 b/app/assets/javascripts/discourse/controllers/invites-show.js.es6
index b710b30..2182b88 100644
--- a/app/assets/javascripts/discourse/controllers/invites-show.js.es6
+++ b/app/assets/javascripts/discourse/controllers/invites-show.js.es6
@@ -37,13 +37,7 @@ export default Ember.Controller.extend(
 
     @computed
     externalAuthsEnabled() {
-      return (
-        findLoginMethods(
-          this.siteSettings,
-          this.capabilities,
-          this.site.isMobileDevice
-        ).length > 0
-      );
+      return findLoginMethods().length > 0;
     },
 
     @computed(
diff --git a/app/assets/javascripts/discourse/controllers/login.js.es6 b/app/assets/javascripts/discourse/controllers/login.js.es6
index bba1b31..63326b8 100644
--- a/app/assets/javascripts/discourse/controllers/login.js.es6
+++ b/app/assets/javascripts/discourse/controllers/login.js.es6
@@ -69,7 +69,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
   // Determines whether at least one login button is enabled
   @computed("canLoginLocalWithEmail")
   hasAtLeastOneLoginButton(canLoginLocalWithEmail) {
-    return findAll(this.siteSettings).length > 0 || canLoginLocalWithEmail;
+    return findAll().length > 0 || canLoginLocalWithEmail;
   },
 
   @computed("loggingIn")
@@ -212,8 +212,17 @@ export default Ember.Controller.extend(ModalFunctionality, {
       return false;
     },
 
-    externalLogin(loginMethod) {
-      loginMethod.doLogin();
+    externalLogin(loginMethod, { fullScreenLogin = false } = {}) {
+      const capabilities = this.capabilities;
+      // On Mobile, Android or iOS always go with full screen
+      if (
+        this.isMobileDevice ||
+        (capabilities && (capabilities.isIOS || capabilities.isAndroid))
+      ) {
+        fullScreenLogin = true;
+      }
+
+      loginMethod.doLogin({ fullScreenLogin });
     },
 
     createAccount() {
@@ -287,11 +296,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
   @computed("authenticate")
   authMessage(authenticate) {
     if (Ember.isEmpty(authenticate)) return "";
-    const method = findAll(
-      this.siteSettings,
-      this.capabilities,
-      this.isMobileDevice
-    ).findBy("name", authenticate);
+    const method = findAll().findBy("name", authenticate);
     if (method) {
       return method.get("message");
     }
diff --git a/app/assets/javascripts/discourse/controllers/preferences/account.js.es6 b/app/assets/javascripts/discourse/controllers/preferences/account.js.es6
index d97c720..303e38e 100644
--- a/app/assets/javascripts/discourse/controllers/preferences/account.js.es6
+++ b/app/assets/javascripts/discourse/controllers/preferences/account.js.es6
@@ -73,11 +73,7 @@ export default Ember.Controller.extend(
 
     @computed("model.associated_accounts.[]")
     authProviders(accounts) {
-      const allMethods = findAll(
-        this.siteSettings,
-        this.capabilities,
-        this.site.isMobileDevice
-      );
+      const allMethods = findAll();
 
       const result = allMethods.map(method => {
         return {
@@ -109,11 +105,7 @@ export default Ember.Controller.extend(
       if (secondFactorEnabled || !canCheckEmails || isAnonymous) {
         return false;
       }
-
-      return (
-        findAll(this.siteSettings, this.capabilities, this.site.isMobileDevice)
-          .length > 0
-      );
+      return findAll().length > 0;
     },
 
     @computed("showAllAuthTokens", "model.user_auth_tokens")
@@ -256,7 +248,7 @@ export default Ember.Controller.extend(
       },
 
       connectAccount(method) {
-        method.doLogin(true);
+        method.doLogin({ reconnect: true, fullScreenLogin: false });
       }
     }
   }
diff --git a/app/assets/javascripts/discourse/models/login-method.js.es6 b/app/assets/javascripts/discourse/models/login-method.js.es6
index d60b492..b5ad270 100644
--- a/app/assets/javascripts/discourse/models/login-method.js.es6
+++ b/app/assets/javascripts/discourse/models/login-method.js.es6
@@ -24,7 +24,7 @@ const LoginMethod = Ember.Object.extend({
     );
   },
 
-  doLogin(reconnect = false) {
+  doLogin({ reconnect = false, fullScreenLogin = true } = {}) {
     const name = this.get("name");
     const customLogin = this.get("customLogin");
 
@@ -37,7 +37,7 @@ const LoginMethod = Ember.Object.extend({
         authUrl += "?reconnect=true";
       }
 
-      if (this.get("full_screen_login")) {
+      if (fullScreenLogin) {
         document.cookie = "fsl=true";
         window.location = authUrl;
       } else {
@@ -79,7 +79,7 @@ const LoginMethod = Ember.Object.extend({
 
 let methods;
 
-export function findAll(siteSettings, capabilities, isMobileDevice) {
+export function findAll() {
   if (methods) {
     return methods;
   }
@@ -90,15 +90,6 @@ export function findAll(siteSettings, capabilities, isMobileDevice) {
     methods.pushObject(LoginMethod.create(provider));
   });
 
-  // On Mobile, Android or iOS always go with full screen
-  if (
-    isMobileDevice ||
-    (capabilities && (capabilities.isIOS || capabilities.isAndroid)) ||
-    Discourse.useFullScreenLogin
-  ) {
-    methods.forEach(m => m.set("full_screen_login", true));
-  }
-
   // exclude FA icon for Google, uses custom SVG
   methods.forEach(m => m.set("isGoogle", m.get("name") === "google_oauth2"));
 
diff --git a/app/assets/javascripts/discourse/routes/application.js.es6 b/app/assets/javascripts/discourse/routes/application.js.es6
index 5d458c5..b6874dd 100644
--- a/app/assets/javascripts/discourse/routes/application.js.es6
+++ b/app/assets/javascripts/discourse/routes/application.js.es6
@@ -252,14 +252,12 @@ const ApplicationRoute = Discourse.Route.extend(OpenComposer, {
   },
 
   _autoLogin(modal, modalClass, notAuto) {
-    const methods = findAll(
-      this.siteSettings,
-      getOwner(this).lookup("capabilities:main"),
-      this.site.isMobileDevice
-    );
+    const methods = findAll();
 
     if (!this.siteSettings.enable_local_logins && methods.length === 1) {
-      this.controllerFor("login").send("externalLogin", methods[0]);
+      this.controllerFor("login").send("externalLogin", methods[0], {
+        fullScreenLogin: true
+      });
     } else {
       showModal(modal);
       this.controllerFor("modal").set("modalClass", modalClass);

[... diff too long, it was truncated ...]

GitHub sha: 427979e7

2 Likes

This commit has been mentioned on Discourse Meta. There might be relevant details there:

FIX: Respect the full_screen_login parameter from plugin auth providers (#7855)