|
|
|
@ -300,7 +300,7 @@ class User < Principal
|
|
|
|
|
attr_accessor :password, :password_confirmation
|
|
|
|
|
attr_accessor :last_before_login_on
|
|
|
|
|
# Prevents unauthorized assignments
|
|
|
|
|
attr_protected :login, :admin, :password, :password_confirmation, :hashed_password
|
|
|
|
|
# attr_protected :login, :admin, :password, :password_confirmation, :hashed_password
|
|
|
|
|
|
|
|
|
|
LOGIN_LENGTH_LIMIT = 30
|
|
|
|
|
MAIL_LENGTH_LIMIT = 60
|
|
|
|
@ -308,15 +308,15 @@ class User < Principal
|
|
|
|
|
#validates_presence_of :login, :mail, :if => Proc.new { |user| !user.is_a?(AnonymousUser) }
|
|
|
|
|
validates_presence_of :login, :if => Proc.new { |user| !user.is_a?(AnonymousUser) }
|
|
|
|
|
validates_uniqueness_of :login, :if => Proc.new { |user| user.login_changed? && user.login.present? }, :case_sensitive => false
|
|
|
|
|
validates_uniqueness_of :mail, :if => Proc.new { |user| user.mail_changed? && user.mail.present? }, :case_sensitive => false
|
|
|
|
|
#validates_uniqueness_of :mail, :if => Proc.new { |user| user.mail_changed? && user.mail.present? }, :case_sensitive => false
|
|
|
|
|
validates_uniqueness_of :phone, :if => Proc.new { |user| user.phone_changed? && user.phone.present? }, :case_sensitive => false
|
|
|
|
|
# Login must contain letters, numbers, underscores only
|
|
|
|
|
#validates_format_of :login, :with => /\A[a-z0-9_\-]*\z/i
|
|
|
|
|
validates_length_of :login, :maximum => LOGIN_LENGTH_LIMIT
|
|
|
|
|
validates_length_of :firstname, :maximum => 30
|
|
|
|
|
validates_length_of :lastname, :maximum => 30
|
|
|
|
|
validates_format_of :mail, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, :allow_blank => true
|
|
|
|
|
validates_length_of :mail, :maximum => MAIL_LENGTH_LIMIT, :allow_nil => true
|
|
|
|
|
#validates_format_of :mail, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, :allow_blank => true
|
|
|
|
|
#validates_length_of :mail, :maximum => MAIL_LENGTH_LIMIT, :allow_nil => true
|
|
|
|
|
validates_confirmation_of :password, :allow_nil => true
|
|
|
|
|
# validates_inclusion_of :mail_notification, :in => MAIL_NOTIFICATION_OPTIONS.collect(&:first), :allow_blank => true
|
|
|
|
|
validate :validate_password_length
|
|
|
|
@ -673,9 +673,9 @@ class User < Principal
|
|
|
|
|
base_reload(*args)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def mail=(arg)
|
|
|
|
|
write_attribute(:mail, arg.to_s.strip)
|
|
|
|
|
end
|
|
|
|
|
# def mail=(arg)
|
|
|
|
|
# write_attribute(:mail, arg.to_s.strip)
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
def identity_url=(url)
|
|
|
|
|
if url.blank?
|
|
|
|
|