From 31cf9be7abacc6cfa325bbcfc7d15aca10af4c99 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Tue, 21 Apr 2009 13:43:57 +0000 Subject: 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 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'app/models') 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 || "") -- cgit v1.2.3