summaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2009-04-21 13:43:57 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2009-04-21 13:43:57 +0000
commit31cf9be7abacc6cfa325bbcfc7d15aca10af4c99 (patch)
treefbfe0f4688c0dd9456afaff3b8c6576f61d69909 /app/models
parent6bb550838777352180534da7a7f807cbf5f0db7f (diff)
downloadredmine-31cf9be7abacc6cfa325bbcfc7d15aca10af4c99.tar.gz
redmine-31cf9be7abacc6cfa325bbcfc7d15aca10af4c99.zip
Makes minimum password length configurable.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2678 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r--app/models/user.rb13
1 files changed, 11 insertions, 2 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 || "")