Skip to content

Instantly share code, notes, and snippets.

@ukstudio
Created June 7, 2010 11:35
Show Gist options
  • Select an option

  • Save ukstudio/428567 to your computer and use it in GitHub Desktop.

Select an option

Save ukstudio/428567 to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
has_many :receipts
include Authentication
include Authentication::ByPassword
validates_presence_of :login
validates_length_of :login, :within => 3..40
validates_uniqueness_of :login
attr_accessible :login, :name, :password, :password_confirmation
def self.authenticate(login, password)
return nil if login.blank? || password.blank?
u = find_by_login(login.downcase) # need to get the salt
u && u.authenticated?(password) ? u : nil
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment