let accounts that don't use cas, saml, or ldap set custom login_handle_name

fixes: CNVS-13196 CNVS-14408 CNVS-14960

accounts that have an AccountAutorizationCofig 
(those that use cas ldap or saml) are able to set 
a login_handle_name (so on the login screen they 
could have it say "USU ID #" instead of "Email"). 
but there are a lot of customers that don't use 
cas, saml or ldap that need to set it too.

for example, a school that uses a csv upload for users.

This allows these accounts to set a custom 
login_handle_name too.

Test plan:

* for an account that does not use cas, saml, or ldap
* go to the account settings page, you should see
  http://cl.ly/image/1W3B3K392p2B
* set something for "Login Label:"
* go to the login screen
* it should use that new value you set

Change-Id: I5a7fd025229a792db4bf898015752024dafa173d
Reviewed-on: https://gerrit.instructure.com/39628
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
QA-Review: Clare Strong <clare@instructure.com>
Product-Review: Hilary Scharton <hilary@instructure.com>
This commit is contained in:
Ryan Shaw 2014-08-20 12:00:32 -06:00
parent a0c74ff3b3
commit 2fdd72d4e5
3 changed files with 37 additions and 5 deletions

View File

@ -166,6 +166,7 @@ class Account < ActiveRecord::Base
add_setting :error_reporting, :hash => true, :values => [:action, :email, :url, :subject_param, :body_param], :root_only => true
add_setting :custom_help_links, :root_only => true
add_setting :prevent_course_renaming_by_teachers, :boolean => true, :root_only => true
add_setting :login_handle_name, :root_only => true
add_setting :restrict_student_future_view, :boolean => true, :root_only => true, :default => false
add_setting :teachers_can_create_courses, :boolean => true, :root_only => true, :default => false
add_setting :students_can_create_courses, :boolean => true, :root_only => true, :default => false
@ -696,14 +697,28 @@ class Account < ActiveRecord::Base
self.account_authorization_configs.first
end
# If an account uses an authorization_config, it's login_handle_name is used.
# Otherwise they can set it on the account settings page.
def login_handle_name_is_customized?
self.account_authorization_config && self.account_authorization_config.login_handle_name.present?
if self.account_authorization_config
self.account_authorization_config.login_handle_name.present?
else
settings[:login_handle_name].present?
end
end
def login_handle_name
login_handle_name_is_customized? ? self.account_authorization_config.login_handle_name :
(self.delegated_authentication? ? AccountAuthorizationConfig.default_delegated_login_handle_name :
AccountAuthorizationConfig.default_login_handle_name)
if login_handle_name_is_customized?
if account_authorization_config
account_authorization_config.login_handle_name
else
settings[:login_handle_name]
end
elsif self.delegated_authentication?
AccountAuthorizationConfig.default_delegated_login_handle_name
else
AccountAuthorizationConfig.default_login_handle_name
end
end
def self_and_all_sub_accounts

View File

@ -78,6 +78,8 @@
line-height: 100%
select
width: 280px
input.same-width-as-select
width: 265px
input[type="checkbox"]
vertical-align: -3px
fieldset

View File

@ -71,7 +71,7 @@
<table class="formtable">
<tr>
<td><%= f.blabel :name, :en => "Account Name" %></td>
<td><%= f.text_field :name %></td>
<td><%= f.text_field :name, :class => 'same-width-as-select' %></td>
</tr>
<% if !@account.root_account? && (@context.sis_source_id && can_do(@context.root_account, @current_user, :read_sis) || can_do(@context.root_account, @current_user, :manage_sis)) %>
<tr>
@ -132,6 +132,21 @@ TEXT
], :selected => @account.settings[:self_enrollment] %>
</td>
</tr>
<% unless @account.account_authorization_config
#if the account has a account_authorization_config, we'll use it's login_handle_name, and this is irrelevant
%>
<tr>
<td><%= settings.blabel :login_handle_name, :en => "Login Label" %></td>
<td>
<%= settings.text_field :login_handle_name,
:value => @account.settings[:login_handle_name],
:class => 'same-width-as-select',
:placeholder => t(:login_handle_name_placeholder, "ex: Login, Username, or Student ID") %>
</td>
</tr>
<% end %>
<tr>
<td colspan="2"><%= settings.check_box :prevent_course_renaming_by_teachers, :checked => @account.settings[:prevent_course_renaming_by_teachers] %>
<%= settings.label :prevent_course_renaming_by_teachers, :en => "Don't let teachers rename their courses" %>