From 31cf9be7abacc6cfa325bbcfc7d15aca10af4c99 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Tue, 21 Apr 2009 13:43:57 +0000 Subject: [PATCH] Makes minimum password length configurable. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2678 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/user.rb | 13 +++++++++++-- app/views/account/register.rhtml | 2 +- app/views/my/password.rhtml | 2 +- app/views/settings/_authentication.rhtml | 3 +++ app/views/users/_form.rhtml | 2 +- config/locales/bg.yml | 1 + config/locales/bs.yml | 1 + config/locales/ca.yml | 1 + config/locales/cs.yml | 1 + config/locales/da.yml | 1 + config/locales/de.yml | 1 + config/locales/en.yml | 1 + config/locales/es.yml | 1 + config/locales/fi.yml | 1 + config/locales/fr.yml | 1 + config/locales/gl.yml | 1 + config/locales/he.yml | 1 + config/locales/hu.yml | 1 + config/locales/it.yml | 1 + config/locales/ja.yml | 1 + config/locales/ko.yml | 1 + config/locales/lt.yml | 1 + config/locales/nl.yml | 1 + config/locales/no.yml | 1 + config/locales/pl.yml | 1 + config/locales/pt-BR.yml | 1 + config/locales/pt.yml | 1 + config/locales/ro.yml | 1 + config/locales/ru.yml | 1 + config/locales/sk.yml | 1 + config/locales/sl.yml | 1 + config/locales/sr.yml | 1 + config/locales/sv.yml | 1 + config/locales/th.yml | 1 + config/locales/tr.yml | 1 + config/locales/uk.yml | 1 + config/locales/vi.yml | 1 + config/locales/zh-TW.yml | 1 + config/locales/zh.yml | 1 + config/settings.yml | 3 +++ 40 files changed, 54 insertions(+), 5 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 63393a6d5..3c9a1c753 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 || "") diff --git a/app/views/account/register.rhtml b/app/views/account/register.rhtml index f9f388ae4..8498d1354 100644 --- a/app/views/account/register.rhtml +++ b/app/views/account/register.rhtml @@ -11,7 +11,7 @@

<%= password_field_tag 'password', nil, :size => 25 %>
-<%= l(:text_caracters_minimum, 4) %>

+<%= l(:text_caracters_minimum, :count => Setting.password_min_length) %>

<%= password_field_tag 'password_confirmation', nil, :size => 25 %>

diff --git a/app/views/my/password.rhtml b/app/views/my/password.rhtml index 2e9fd0fa4..cac79342c 100644 --- a/app/views/my/password.rhtml +++ b/app/views/my/password.rhtml @@ -9,7 +9,7 @@

<%= password_field_tag 'new_password', nil, :size => 25 %>
-<%= l(:text_caracters_minimum, 4) %>

+<%= l(:text_caracters_minimum, :count => Setting.password_min_length) %>

<%= password_field_tag 'new_password_confirmation', nil, :size => 25 %>

diff --git a/app/views/settings/_authentication.rhtml b/app/views/settings/_authentication.rhtml index ec8a0be96..25d344da6 100644 --- a/app/views/settings/_authentication.rhtml +++ b/app/views/settings/_authentication.rhtml @@ -15,6 +15,9 @@ [l(:label_registration_automatic_activation), "3"] ], Setting.self_registration ) %>

+

+<%= text_field_tag 'settings[password_min_length]', Setting.password_min_length, :size => 6 %>

+

<%= check_box_tag 'settings[lost_password]', 1, Setting.lost_password? %><%= hidden_field_tag 'settings[lost_password]', 0 %>

diff --git a/app/views/users/_form.rhtml b/app/views/users/_form.rhtml index 90d6ba577..24e0b912b 100644 --- a/app/views/users/_form.rhtml +++ b/app/views/users/_form.rhtml @@ -27,7 +27,7 @@

<%= password_field_tag 'password', nil, :size => 25 %>
-<%= l(:text_caracters_minimum, 4) %>

+<%= l(:text_caracters_minimum, :count => Setting.password_min_length) %>

<%= password_field_tag 'password_confirmation', nil, :size => 25 %>

diff --git a/config/locales/bg.yml b/config/locales/bg.yml index 500cc5713..0426bd193 100644 --- a/config/locales/bg.yml +++ b/config/locales/bg.yml @@ -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 diff --git a/config/locales/bs.yml b/config/locales/bs.yml index a064372ef..3a4fe13e2 100644 --- a/config/locales/bs.yml +++ b/config/locales/bs.yml @@ -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 diff --git a/config/locales/ca.yml b/config/locales/ca.yml index 8d435241d..75c269080 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -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 diff --git a/config/locales/cs.yml b/config/locales/cs.yml index ab8f27fc8..c6cb412d1 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -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 diff --git a/config/locales/da.yml b/config/locales/da.yml index 704c5e4e8..ec4a81256 100644 --- a/config/locales/da.yml +++ b/config/locales/da.yml @@ -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 diff --git a/config/locales/de.yml b/config/locales/de.yml index 3f9cd17a6..9628f5819 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -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 diff --git a/config/locales/en.yml b/config/locales/en.yml index fd1ed6c51..855766039 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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 diff --git a/config/locales/es.yml b/config/locales/es.yml index c37b96c64..c82b3ac50 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -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 diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 9c35cb449..572d25c85 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -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 diff --git a/config/locales/fr.yml b/config/locales/fr.yml index ddd349c69..9d6aad122 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -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 diff --git a/config/locales/gl.yml b/config/locales/gl.yml index 9ccd9574e..8e5b98001 100644 --- a/config/locales/gl.yml +++ b/config/locales/gl.yml @@ -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 diff --git a/config/locales/he.yml b/config/locales/he.yml index 4941240b7..40ae33a7f 100644 --- a/config/locales/he.yml +++ b/config/locales/he.yml @@ -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 diff --git a/config/locales/hu.yml b/config/locales/hu.yml index a4ac468e7..ece1d11b7 100644 --- a/config/locales/hu.yml +++ b/config/locales/hu.yml @@ -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 diff --git a/config/locales/it.yml b/config/locales/it.yml index 58ee928ab..0aa19443d 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -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 diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 5574aee63..1d07aefa8 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -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 diff --git a/config/locales/ko.yml b/config/locales/ko.yml index 0b323fe1e..85b49c5f2 100644 --- a/config/locales/ko.yml +++ b/config/locales/ko.yml @@ -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 diff --git a/config/locales/lt.yml b/config/locales/lt.yml index dd6b029ca..8ee71b42f 100644 --- a/config/locales/lt.yml +++ b/config/locales/lt.yml @@ -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 diff --git a/config/locales/nl.yml b/config/locales/nl.yml index b5728fbb3..8aea6cb23 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -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 diff --git a/config/locales/no.yml b/config/locales/no.yml index 3eb1dbaba..83041cf10 100644 --- a/config/locales/no.yml +++ b/config/locales/no.yml @@ -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 diff --git a/config/locales/pl.yml b/config/locales/pl.yml index 936683e84..105b4e169 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -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 diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index bd065e5d3..80883adfd 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -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 diff --git a/config/locales/pt.yml b/config/locales/pt.yml index aa8e672d5..f2b08ec2e 100644 --- a/config/locales/pt.yml +++ b/config/locales/pt.yml @@ -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 diff --git a/config/locales/ro.yml b/config/locales/ro.yml index fe144c703..e7dd09b94 100644 --- a/config/locales/ro.yml +++ b/config/locales/ro.yml @@ -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 diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 668a2c7da..844a82bd3 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -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 diff --git a/config/locales/sk.yml b/config/locales/sk.yml index 6cd573fb1..37a3fefc3 100644 --- a/config/locales/sk.yml +++ b/config/locales/sk.yml @@ -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 diff --git a/config/locales/sl.yml b/config/locales/sl.yml index 5ccd5b7fd..079e488a6 100644 --- a/config/locales/sl.yml +++ b/config/locales/sl.yml @@ -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 diff --git a/config/locales/sr.yml b/config/locales/sr.yml index b2b61a1c2..09220c913 100644 --- a/config/locales/sr.yml +++ b/config/locales/sr.yml @@ -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 diff --git a/config/locales/sv.yml b/config/locales/sv.yml index d532d4aa3..b3e3c139c 100644 --- a/config/locales/sv.yml +++ b/config/locales/sv.yml @@ -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 diff --git a/config/locales/th.yml b/config/locales/th.yml index 9de605691..a19f315ef 100644 --- a/config/locales/th.yml +++ b/config/locales/th.yml @@ -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 diff --git a/config/locales/tr.yml b/config/locales/tr.yml index 068c4ec41..0d47a8c84 100644 --- a/config/locales/tr.yml +++ b/config/locales/tr.yml @@ -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 diff --git a/config/locales/uk.yml b/config/locales/uk.yml index 23edbd172..0762090b6 100644 --- a/config/locales/uk.yml +++ b/config/locales/uk.yml @@ -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 diff --git a/config/locales/vi.yml b/config/locales/vi.yml index 0a8f82156..6190a1940 100644 --- a/config/locales/vi.yml +++ b/config/locales/vi.yml @@ -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 diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index 7a322c102..86288a9b5 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -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 diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 5ae2411bf..83bd5bcf1 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -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 diff --git a/config/settings.yml b/config/settings.yml index 38b0a44c8..5d4d6ff14 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -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 -- 2.39.5