summaryrefslogtreecommitdiffstats
path: root/app/models/user.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2011-12-18 15:48:06 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2011-12-18 15:48:06 +0000
commitf5987a5ca0660c6e77f6e4c899d02f3e5552538a (patch)
treed9dc0a86511792bca2f503c664b96248c72d2243 /app/models/user.rb
parent14ea087edc762e068a8a65b40313caabd1de6ea3 (diff)
downloadredmine-f5987a5ca0660c6e77f6e4c899d02f3e5552538a.tar.gz
redmine-f5987a5ca0660c6e77f6e4c899d02f3e5552538a.zip
Use validation callback.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8293 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/user.rb')
-rw-r--r--app/models/user.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index efe5b30a3..5eff881cb 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -259,7 +259,7 @@ class User < Principal
# Does the backend storage allow this user to change their password?
def change_password_allowed?
- return true if auth_source_id.blank?
+ return true if auth_source.nil?
return auth_source.allow_password_changes?
end
@@ -621,8 +621,9 @@ class User < Principal
end
class AnonymousUser < User
-
- def validate_on_create
+ validate :validate_anonymous_uniqueness, :on => :create
+
+ def validate_anonymous_uniqueness
# There should be only one AnonymousUser in the database
errors.add :base, 'An anonymous user already exists.' if AnonymousUser.find(:first)
end