validates_length_of :pass_crypt, :minimum => 8
validates_length_of :display_name, :minimum => 3, :allow_nil => true
validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
+ validates_format_of :display_name, :with => /^[^\/;.,?]*$/
before_save :encrypt_password
end
def encrypt_password
- self.pass_crypt = Digest::MD5.hexdigest(pass_crypt) if pass_crypt_confirmation
+ self.pass_crypt = Digest::MD5.hexdigest(pass_crypt) unless pass_crypt_confirmation.nil?
end
- def self.authenticate(email, passwd)
- find(:first, :conditions => [ "email = ? AND pass_crypt = ? AND active = true", email, Digest::MD5.hexdigest(passwd)])
+ def self.authenticate(email, passwd, active = true)
+ find(:first, :conditions => [ "email = ? AND pass_crypt = ? AND active = ?", email, Digest::MD5.hexdigest(passwd), active])
end
def self.authenticate_token(token)