-
Code's Tags
-
Your Codes
-
Reffers
-
Linked Codes
|
Code:
Short link for Twitter:
HTML:
HTML view:
Copy Source | Copy HTML require 'digest/sha1' class User < ActiveRecord::Base include Authentication include Authentication::ByPassword include Authentication::ByCookieToken validates_format_of :name, :with => Authentication.name_regex, :message => Authentication.bad_name_message, :allow_nil => true validates_length_of :name, :maximum => 100 validates_presence_of :email validates_length_of :email, :within => 6..100 validates_uniqueness_of :email validates_format_of :email, :with => Authentication.email_regex, :message => Authentication.bad_email_message attr_accessible :email, :name, :password, :password_confirmation def self.authenticate(login, password) return nil if login.blank? || password.blank? u = find_by_email(login.downcase) # need to get the salt u && u.authenticated?(password) ? u : nil end def email=(value) write_attribute :email, (value ? value.downcase : nil) end end
|