X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/8ae5d94b2f16d6f2cf1739e19ebc3793a18a0a4a..af2b13c2c1c220326241784b1d237d85ff388426:/app/models/user.rb diff --git a/app/models/user.rb b/app/models/user.rb index 759c8d0b0..56c8890b5 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -18,11 +18,14 @@ class User < ActiveRecord::Base has_many :active_blocks, :class_name => "UserBlock", :conditions => proc { [ "user_blocks.ends_at > :ends_at or user_blocks.needs_view", { :ends_at => Time.now.getutc } ] } has_many :roles, :class_name => "UserRole" + scope :visible, where(:status => ["pending", "active", "confirmed"]) + scope :active, where(:status => ["active", "confirmed"]) + validates_presence_of :email, :display_name validates_confirmation_of :email#, :message => ' addresses must match' validates_confirmation_of :pass_crypt#, :message => ' must match the confirmation password' - validates_uniqueness_of :display_name, :allow_nil => true - validates_uniqueness_of :email + validates_uniqueness_of :display_name, :allow_nil => true, :case_sensitive => false, :if => Proc.new { |u| u.display_name_changed? } + validates_uniqueness_of :email, :case_sensitive => false, :if => Proc.new { |u| u.email_changed? } validates_uniqueness_of :openid_url, :allow_nil => true validates_length_of :pass_crypt, :within => 8..255 validates_length_of :display_name, :within => 3..255, :allow_nil => true