From 0bdee973a05dd4aaaeb112c2111a546a2b5126cc Mon Sep 17 00:00:00 2001 From: Erik Ordway <ordwaye@evergreen.edu> Date: Thu, 23 May 2013 13:44:14 -0700 Subject: [PATCH] allow disabling of local logins. In the instance where an .edu is using cas they may not want a user to be able to log in once the users credentials have been revoked in the system that feeds the CAS authentication server. This is very optional --- .../templates/modal/login.js.handlebars | 52 +++++++++++-------- app/models/site_setting.rb | 3 ++ config/locales/server.en.yml | 2 + 3 files changed, 34 insertions(+), 23 deletions(-) diff --git a/app/assets/javascripts/discourse/templates/modal/login.js.handlebars b/app/assets/javascripts/discourse/templates/modal/login.js.handlebars index 32f55efa9..d5dee05da 100644 --- a/app/assets/javascripts/discourse/templates/modal/login.js.handlebars +++ b/app/assets/javascripts/discourse/templates/modal/login.js.handlebars @@ -23,30 +23,34 @@ <button class="btn btn-social persona" title="{{i18n login.persona.title}}" {{action "personaLogin" target="view"}}>{{i18n login.persona.title}}</button> {{/if}} </div> - <h3 style="text-align:center; margin-bottom:10px;">{{i18n login.or}}</h3> {{/if}} - <form id='login-form'> - <div> - <table> - <tr> - <td> - <label for='login-account-name'>{{i18n login.username}} </label> - </td> - <td> - {{textField value=view.loginName placeholderKey="login.email_placeholder" id="login-account-name" autocorrect="off" autocapitalize="off" autofocus="autofocus"}} - </td> - <tr> - <td> - <label for='login-account-password'>{{i18n login.password}} </label> - </td> - <td> - {{textField value=view.loginPassword type="password" id="login-account-password"}} - <a id="forgot-password-link" {{action forgotPassword target="view"}}>{{i18n forgot_password.action}}</a> - </td> - </tr> - </table> - </div> - </form> + {{#if Discourse.SiteSettings.enable_local_logins}} + {{#if view.hasAtLeastOneLoginButton}} + <h3 style="text-align:center; margin-bottom:10px;">{{i18n login.or}}</h3> + {{/if}} + <form id='login-form'> + <div> + <table> + <tr> + <td> + <label for='login-account-name'>{{i18n login.username}} </label> + </td> + <td> + {{textField value=view.loginName placeholderKey="login.email_placeholder" id="login-account-name" autocorrect="off" autocapitalize="off" autofocus="autofocus"}} + </td> + <tr> + <td> + <label for='login-account-password'>{{i18n login.password}} </label> + </td> + <td> + {{textField value=view.loginPassword type="password" id="login-account-password"}} + <a id="forgot-password-link" {{action forgotPassword target="view"}}>{{i18n forgot_password.action}}</a> + </td> + </tr> + </table> + </div> + </form> + {{/if}} {{view.authMessage}} <div id='login-alert' {{bindAttr class="view.alertClass"}}>{{view.alert}}</div> </div> @@ -54,7 +58,9 @@ {{#if view.authenticate}} {{i18n login.authenticating}} {{/if}} + {{#if Discourse.SiteSettings.enable_local_logins}} <button class='btn btn-large btn-primary' {{bindAttr disabled="view.loginDisabled"}} {{action login target="view"}}><i class="icon-unlock"></i> {{view.loginButtonText}}</button> {{i18n create_account.invite}} <a id="new-account-link" {{action newAccount target="view"}}>{{i18n create_account.action}}</a> + {{/if}} </div> diff --git a/app/models/site_setting.rb b/app/models/site_setting.rb index 1635b3185..9066ae166 100644 --- a/app/models/site_setting.rb +++ b/app/models/site_setting.rb @@ -129,6 +129,9 @@ class SiteSetting < ActiveRecord::Base setting(:send_welcome_message, true) + client_setting(:enable_local_logins, true) + client_setting(:enable_local_account_create, true) + client_setting(:enable_google_logins, true) client_setting(:enable_yahoo_logins, true) diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 8d07f2d37..f22d4be7d 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -493,6 +493,8 @@ en: # TODO: perhaps we need a way of protecting these settings for hosted solution, global settings ... + enable_local_logins: "Enable local authentication" + enable_local_account_create: "Enable local account creation" enable_google_logins: "Enable Google authentication" enable_yahoo_logins: "Enable Yahoo authentication"