From f5987a5ca0660c6e77f6e4c899d02f3e5552538a 2011-12-18 15:48:06 From: Jean-Philippe Lang Date: 2011-12-18 15:48:06 Subject: [PATCH] Use validation callback. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8293 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/models/user.rb b/app/models/user.rb index efe5b30..5eff881 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