From 58322617ec456f37e956e119f7f1461f7cec2b99 Mon Sep 17 00:00:00 2001 From: Sam Saffron Date: Thu, 11 Aug 2016 23:15:45 +1000 Subject: [PATCH] UX: on mobile devices iOS or Android always use full screen login This simplifies life for users and embedded browsers and works around all popup blocking. There is no point to popup tabs on Android or iOS, it just causes confusion. --- app/assets/javascripts/discourse/controllers/login.js.es6 | 2 +- .../javascripts/discourse/models/login-method.js.es6 | 8 +++++++- .../javascripts/discourse/routes/application.js.es6 | 6 +++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/login.js.es6 b/app/assets/javascripts/discourse/controllers/login.js.es6 index 4abefa97b..f2ba67bb6 100644 --- a/app/assets/javascripts/discourse/controllers/login.js.es6 +++ b/app/assets/javascripts/discourse/controllers/login.js.es6 @@ -176,7 +176,7 @@ export default Ember.Controller.extend(ModalFunctionality, { authMessage: (function() { if (Ember.isEmpty(this.get('authenticate'))) return ""; - const method = findAll(this.siteSettings).findProperty("name", this.get("authenticate")); + const method = findAll(this.siteSettings, this.capabilities, this.isMobileDevice).findProperty("name", this.get("authenticate")); if(method){ return method.get('message'); } diff --git a/app/assets/javascripts/discourse/models/login-method.js.es6 b/app/assets/javascripts/discourse/models/login-method.js.es6 index 254c401cf..e1cd941a2 100644 --- a/app/assets/javascripts/discourse/models/login-method.js.es6 +++ b/app/assets/javascripts/discourse/models/login-method.js.es6 @@ -22,7 +22,7 @@ const LoginMethod = Ember.Object.extend({ let methods; let preRegister; -export function findAll(siteSettings) { +export function findAll(siteSettings, capabilities, isMobileDevice) { if (methods) { return methods; } methods = []; @@ -55,6 +55,12 @@ export function findAll(siteSettings) { }); preRegister = undefined; } + + // On Mobile, Android or iOS always go with full screen + if (isMobileDevice || capabilities.isIOS || capabilities.isAndroid) { + methods.forEach(m=>m.set("fullScreenLogin", true)); + } + return methods; } diff --git a/app/assets/javascripts/discourse/routes/application.js.es6 b/app/assets/javascripts/discourse/routes/application.js.es6 index 2b216ce15..f34b5ffcd 100644 --- a/app/assets/javascripts/discourse/routes/application.js.es6 +++ b/app/assets/javascripts/discourse/routes/application.js.es6 @@ -204,7 +204,11 @@ const ApplicationRoute = Discourse.Route.extend(OpenComposer, { }, _autoLogin(modal, modalClass, notAuto) { - const methods = findAll(this.siteSettings); + + const methods = findAll(this.siteSettings, + this.container.lookup('capabilities:main'), + this.site.isMobileDevice); + if (!this.siteSettings.enable_local_logins && methods.length === 1) { this.controllerFor('login').send('externalLogin', methods[0]); } else {