Makes minimum password length configurable.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2678 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2009-04-21 13:43:57 +00:00
parent 6bb5508387
commit 31cf9be7ab
40 changed files with 54 additions and 5 deletions

View File

@ -62,7 +62,6 @@ class User < ActiveRecord::Base
validates_length_of :firstname, :lastname, :maximum => 30
validates_format_of :mail, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :allow_nil => true
validates_length_of :mail, :maximum => 60, :allow_nil => true
validates_length_of :password, :minimum => 4, :allow_nil => true
validates_confirmation_of :password, :allow_nil => true
def before_create
@ -297,7 +296,17 @@ class User < ActiveRecord::Base
anonymous_user
end
private
protected
def validate
# Password length validation based on setting
if !password.nil? && password.size < Setting.password_min_length.to_i
errors.add(:password, :too_short, :count => Setting.password_min_length.to_i)
end
end
private
# Return password digest
def self.hash_password(clear_password)
Digest::SHA1.hexdigest(clear_password || "")

View File

@ -11,7 +11,7 @@
<p><label for="password"><%=l(:field_password)%> <span class="required">*</span></label>
<%= password_field_tag 'password', nil, :size => 25 %><br />
<em><%= l(:text_caracters_minimum, 4) %></em></p>
<em><%= l(:text_caracters_minimum, :count => Setting.password_min_length) %></em></p>
<p><label for="password_confirmation"><%=l(:field_password_confirmation)%> <span class="required">*</span></label>
<%= password_field_tag 'password_confirmation', nil, :size => 25 %></p>

View File

@ -9,7 +9,7 @@
<p><label for="new_password"><%=l(:field_new_password)%> <span class="required">*</span></label>
<%= password_field_tag 'new_password', nil, :size => 25 %><br />
<em><%= l(:text_caracters_minimum, 4) %></em></p>
<em><%= l(:text_caracters_minimum, :count => Setting.password_min_length) %></em></p>
<p><label for="new_password_confirmation"><%=l(:field_password_confirmation)%> <span class="required">*</span></label>
<%= password_field_tag 'new_password_confirmation', nil, :size => 25 %></p>

View File

@ -15,6 +15,9 @@
[l(:label_registration_automatic_activation), "3"]
], Setting.self_registration ) %></p>
<p><label><%= l(:setting_password_min_length) %></label>
<%= text_field_tag 'settings[password_min_length]', Setting.password_min_length, :size => 6 %></p>
<p><label><%= l(:label_password_lost) %></label>
<%= check_box_tag 'settings[lost_password]', 1, Setting.lost_password? %><%= hidden_field_tag 'settings[lost_password]', 0 %></p>

View File

@ -27,7 +27,7 @@
<div id="password_fields" style="<%= 'display:none;' if @user.auth_source %>">
<p><label for="password"><%=l(:field_password)%><span class="required"> *</span></label>
<%= password_field_tag 'password', nil, :size => 25 %><br />
<em><%= l(:text_caracters_minimum, 4) %></em></p>
<em><%= l(:text_caracters_minimum, :count => Setting.password_min_length) %></em></p>
<p><label for="password_confirmation"><%=l(:field_password_confirmation)%><span class="required"> *</span></label>
<%= password_field_tag 'password_confirmation', nil, :size => 25 %></p>
</div>

View File

@ -788,3 +788,4 @@ bg:
text_wiki_page_reassign_children: Reassign child pages to this parent page
text_wiki_page_nullify_children: Keep child pages as root pages
text_wiki_page_destroy_children: Delete child pages and all their descendants
setting_password_min_length: Minimum password length

View File

@ -821,3 +821,4 @@ bs:
text_wiki_page_reassign_children: Reassign child pages to this parent page
text_wiki_page_nullify_children: Keep child pages as root pages
text_wiki_page_destroy_children: Delete child pages and all their descendants
setting_password_min_length: Minimum password length

View File

@ -791,3 +791,4 @@ ca:
text_wiki_page_reassign_children: Reassign child pages to this parent page
text_wiki_page_nullify_children: Keep child pages as root pages
text_wiki_page_destroy_children: Delete child pages and all their descendants
setting_password_min_length: Minimum password length

View File

@ -794,3 +794,4 @@ cs:
text_wiki_page_reassign_children: Reassign child pages to this parent page
text_wiki_page_nullify_children: Keep child pages as root pages
text_wiki_page_destroy_children: Delete child pages and all their descendants
setting_password_min_length: Minimum password length

View File

@ -821,3 +821,4 @@ da:
text_wiki_page_reassign_children: Reassign child pages to this parent page
text_wiki_page_nullify_children: Keep child pages as root pages
text_wiki_page_destroy_children: Delete child pages and all their descendants
setting_password_min_length: Minimum password length

View File

@ -820,3 +820,4 @@ de:
text_wiki_page_reassign_children: Reassign child pages to this parent page
text_wiki_page_nullify_children: Keep child pages as root pages
text_wiki_page_destroy_children: Delete child pages and all their descendants
setting_password_min_length: Minimum password length

View File

@ -285,6 +285,7 @@ en:
setting_file_max_size_displayed: Max size of text files displayed inline
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
setting_openid: Allow OpenID login and registration
setting_password_min_length: Minimum password length
permission_edit_project: Edit project
permission_select_project_modules: Select project modules

View File

@ -841,3 +841,4 @@ es:
text_wiki_page_reassign_children: Reassign child pages to this parent page
text_wiki_page_nullify_children: Keep child pages as root pages
text_wiki_page_destroy_children: Delete child pages and all their descendants
setting_password_min_length: Minimum password length

View File

@ -831,3 +831,4 @@ fi:
text_wiki_page_reassign_children: Reassign child pages to this parent page
text_wiki_page_nullify_children: Keep child pages as root pages
text_wiki_page_destroy_children: Delete child pages and all their descendants
setting_password_min_length: Minimum password length

View File

@ -317,6 +317,7 @@ fr:
setting_file_max_size_displayed: Taille maximum des fichiers texte affichés en ligne
setting_repository_log_display_limit: "Nombre maximum de revisions affichées sur l'historique d'un fichier"
setting_openid: "Autoriser l'authentification et l'enregistrement OpenID"
setting_password_min_length: Longueur minimum des mots de passe
permission_edit_project: Modifier le projet
permission_select_project_modules: Choisir les modules

View File

@ -820,3 +820,4 @@ gl:
text_wiki_page_reassign_children: Reassign child pages to this parent page
text_wiki_page_nullify_children: Keep child pages as root pages
text_wiki_page_destroy_children: Delete child pages and all their descendants
setting_password_min_length: Minimum password length

View File

@ -803,3 +803,4 @@ he:
text_wiki_page_reassign_children: Reassign child pages to this parent page
text_wiki_page_nullify_children: Keep child pages as root pages
text_wiki_page_destroy_children: Delete child pages and all their descendants
setting_password_min_length: Minimum password length

View File

@ -826,3 +826,4 @@
text_wiki_page_reassign_children: Reassign child pages to this parent page
text_wiki_page_nullify_children: Keep child pages as root pages
text_wiki_page_destroy_children: Delete child pages and all their descendants
setting_password_min_length: Minimum password length

View File

@ -806,3 +806,4 @@ it:
text_wiki_page_reassign_children: Reassign child pages to this parent page
text_wiki_page_nullify_children: Keep child pages as root pages
text_wiki_page_destroy_children: Delete child pages and all their descendants
setting_password_min_length: Minimum password length

View File

@ -819,3 +819,4 @@ ja:
text_wiki_page_reassign_children: Reassign child pages to this parent page
text_wiki_page_nullify_children: Keep child pages as root pages
text_wiki_page_destroy_children: Delete child pages and all their descendants
setting_password_min_length: Minimum password length

View File

@ -850,3 +850,4 @@ ko:
text_wiki_page_reassign_children: Reassign child pages to this parent page
text_wiki_page_nullify_children: Keep child pages as root pages
text_wiki_page_destroy_children: Delete child pages and all their descendants
setting_password_min_length: Minimum password length

View File

@ -831,3 +831,4 @@ lt:
text_wiki_page_reassign_children: Reassign child pages to this parent page
text_wiki_page_nullify_children: Keep child pages as root pages
text_wiki_page_destroy_children: Delete child pages and all their descendants
setting_password_min_length: Minimum password length

View File

@ -776,3 +776,4 @@ nl:
text_wiki_page_reassign_children: Reassign child pages to this parent page
text_wiki_page_nullify_children: Keep child pages as root pages
text_wiki_page_destroy_children: Delete child pages and all their descendants
setting_password_min_length: Minimum password length

View File

@ -793,3 +793,4 @@
text_wiki_page_reassign_children: Reassign child pages to this parent page
text_wiki_page_nullify_children: Keep child pages as root pages
text_wiki_page_destroy_children: Delete child pages and all their descendants
setting_password_min_length: Minimum password length

View File

@ -824,3 +824,4 @@ pl:
text_wiki_page_reassign_children: Reassign child pages to this parent page
text_wiki_page_nullify_children: Keep child pages as root pages
text_wiki_page_destroy_children: Delete child pages and all their descendants
setting_password_min_length: Minimum password length

View File

@ -826,3 +826,4 @@ pt-BR:
text_wiki_page_reassign_children: Reassign child pages to this parent page
text_wiki_page_nullify_children: Keep child pages as root pages
text_wiki_page_destroy_children: Delete child pages and all their descendants
setting_password_min_length: Minimum password length

View File

@ -812,3 +812,4 @@ pt:
text_wiki_page_reassign_children: Reassign child pages to this parent page
text_wiki_page_nullify_children: Keep child pages as root pages
text_wiki_page_destroy_children: Delete child pages and all their descendants
setting_password_min_length: Minimum password length

View File

@ -791,3 +791,4 @@ ro:
text_wiki_page_reassign_children: Reassign child pages to this parent page
text_wiki_page_nullify_children: Keep child pages as root pages
text_wiki_page_destroy_children: Delete child pages and all their descendants
setting_password_min_length: Minimum password length

View File

@ -918,3 +918,4 @@ ru:
text_wiki_page_reassign_children: Reassign child pages to this parent page
text_wiki_page_nullify_children: Keep child pages as root pages
text_wiki_page_destroy_children: Delete child pages and all their descendants
setting_password_min_length: Minimum password length

View File

@ -792,3 +792,4 @@ sk:
text_wiki_page_reassign_children: Reassign child pages to this parent page
text_wiki_page_nullify_children: Keep child pages as root pages
text_wiki_page_destroy_children: Delete child pages and all their descendants
setting_password_min_length: Minimum password length

View File

@ -790,3 +790,4 @@ sl:
text_wiki_page_reassign_children: Reassign child pages to this parent page
text_wiki_page_nullify_children: Keep child pages as root pages
text_wiki_page_destroy_children: Delete child pages and all their descendants
setting_password_min_length: Minimum password length

View File

@ -814,3 +814,4 @@
text_wiki_page_reassign_children: Reassign child pages to this parent page
text_wiki_page_nullify_children: Keep child pages as root pages
text_wiki_page_destroy_children: Delete child pages and all their descendants
setting_password_min_length: Minimum password length

View File

@ -848,3 +848,4 @@ sv:
text_wiki_page_reassign_children: Reassign child pages to this parent page
text_wiki_page_nullify_children: Keep child pages as root pages
text_wiki_page_destroy_children: Delete child pages and all their descendants
setting_password_min_length: Minimum password length

View File

@ -791,3 +791,4 @@ th:
text_wiki_page_reassign_children: Reassign child pages to this parent page
text_wiki_page_nullify_children: Keep child pages as root pages
text_wiki_page_destroy_children: Delete child pages and all their descendants
setting_password_min_length: Minimum password length

View File

@ -827,3 +827,4 @@ tr:
text_wiki_page_reassign_children: Reassign child pages to this parent page
text_wiki_page_nullify_children: Keep child pages as root pages
text_wiki_page_destroy_children: Delete child pages and all their descendants
setting_password_min_length: Minimum password length

View File

@ -790,3 +790,4 @@ uk:
text_wiki_page_reassign_children: Reassign child pages to this parent page
text_wiki_page_nullify_children: Keep child pages as root pages
text_wiki_page_destroy_children: Delete child pages and all their descendants
setting_password_min_length: Minimum password length

View File

@ -860,3 +860,4 @@ vi:
text_wiki_page_reassign_children: Reassign child pages to this parent page
text_wiki_page_nullify_children: Keep child pages as root pages
text_wiki_page_destroy_children: Delete child pages and all their descendants
setting_password_min_length: Minimum password length

View File

@ -898,3 +898,4 @@
text_wiki_page_reassign_children: Reassign child pages to this parent page
text_wiki_page_nullify_children: Keep child pages as root pages
text_wiki_page_destroy_children: Delete child pages and all their descendants
setting_password_min_length: Minimum password length

View File

@ -823,3 +823,4 @@ zh:
text_wiki_page_reassign_children: Reassign child pages to this parent page
text_wiki_page_nullify_children: Keep child pages as root pages
text_wiki_page_destroy_children: Delete child pages and all their descendants
setting_password_min_length: Minimum password length

View File

@ -31,6 +31,9 @@ self_registration:
default: '2'
lost_password:
default: 1
password_min_length:
format: int
default: 4
attachment_max_size:
format: int
default: 5120