From 7c2618e914added176ce2a0625eb511469339ed9 Mon Sep 17 00:00:00 2001 From: Kris Date: Fri, 26 Oct 2018 10:33:06 -0400 Subject: [PATCH] Adding classes to login for external auth and user fields (#6535) --- .../discourse/controllers/create-account.js.es6 | 6 ++++++ app/assets/javascripts/discourse/controllers/login.js.es6 | 7 ++++--- .../discourse/templates/modal/create-account.hbs | 2 +- app/assets/javascripts/discourse/templates/modal/login.hbs | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/create-account.js.es6 b/app/assets/javascripts/discourse/controllers/create-account.js.es6 index c4f1b20fc50..fe51b0ca486 100644 --- a/app/assets/javascripts/discourse/controllers/create-account.js.es6 +++ b/app/assets/javascripts/discourse/controllers/create-account.js.es6 @@ -9,6 +9,7 @@ import UsernameValidation from "discourse/mixins/username-validation"; import NameValidation from "discourse/mixins/name-validation"; import UserFieldsValidation from "discourse/mixins/user-fields-validation"; import { userPath } from "discourse/lib/url"; +import { findAll } from "discourse/models/login-method"; export default Ember.Controller.extend( ModalFunctionality, @@ -176,6 +177,11 @@ export default Ember.Controller.extend( } }.observes("emailValidation", "accountEmail"), + // Determines whether at least one login button is enabled + hasAtLeastOneLoginButton: function() { + return findAll(this.siteSettings).length > 0; + }.property(), + @on("init") fetchConfirmationValue() { return ajax(userPath("hp.json")).then(json => { diff --git a/app/assets/javascripts/discourse/controllers/login.js.es6 b/app/assets/javascripts/discourse/controllers/login.js.es6 index 1729950acf3..75fa364e914 100644 --- a/app/assets/javascripts/discourse/controllers/login.js.es6 +++ b/app/assets/javascripts/discourse/controllers/login.js.es6 @@ -57,9 +57,10 @@ export default Ember.Controller.extend(ModalFunctionality, { }, // Determines whether at least one login button is enabled - hasAtLeastOneLoginButton: function() { - return findAll(this.siteSettings).length > 0; - }.property(), + @computed("canLoginLocalWithEmail") + hasAtLeastOneLoginButton(canLoginLocalWithEmail) { + return findAll(this.siteSettings).length > 0 || canLoginLocalWithEmail; + }, @computed("loggingIn") loginButtonLabel(loggingIn) { diff --git a/app/assets/javascripts/discourse/templates/modal/create-account.hbs b/app/assets/javascripts/discourse/templates/modal/create-account.hbs index 7b5537db8cd..ed31247a81c 100644 --- a/app/assets/javascripts/discourse/templates/modal/create-account.hbs +++ b/app/assets/javascripts/discourse/templates/modal/create-account.hbs @@ -1,6 +1,6 @@ {{#create-account email=accountEmail disabled=submitDisabled action="createAccount"}} {{#unless complete}} - {{#d-modal-body title="create_account.title"}} + {{#d-modal-body title="create_account.title" class=(concat (if hasAtLeastOneLoginButton "has-alt-auth") " " (if userFields "has-user-fields"))}} {{#unless hasAuthOptions}} {{login-buttons externalLogin="externalLogin"}} diff --git a/app/assets/javascripts/discourse/templates/modal/login.hbs b/app/assets/javascripts/discourse/templates/modal/login.hbs index 05f519fd04d..67463aed053 100644 --- a/app/assets/javascripts/discourse/templates/modal/login.hbs +++ b/app/assets/javascripts/discourse/templates/modal/login.hbs @@ -1,5 +1,5 @@ {{#login-modal screenX=lastX screenY=lastY loginName=loginName loginPassword=loginPassword loginSecondFactor=loginSecondFactor action="login"}} - {{#d-modal-body title="login.title" class="login-modal"}} + {{#d-modal-body title="login.title" class=(concat "login-modal" " " (if hasAtLeastOneLoginButton "has-alt-auth"))}} {{#if canLoginLocal}}