]> source.dussan.org Git - redmine.git/commitdiff
Use validation callback.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 18 Dec 2011 15:48:06 +0000 (15:48 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 18 Dec 2011 15:48:06 +0000 (15:48 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8293 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/user.rb

index efe5b30a341aaee50d1cb10cddcfdb055cc0a50d..5eff881cb2ddb40e1128d53b7f214291c8330849 100644 (file)
@@ -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