Skip to content

Instantly share code, notes, and snippets.

@tokumine
Created October 13, 2008 12:49
Show Gist options
  • Save tokumine/16529 to your computer and use it in GitHub Desktop.
Save tokumine/16529 to your computer and use it in GitHub Desktop.
# Username or email login for restful_authentication in user.rb model
def self.authenticate(login, password)
return nil if login.blank? || password.blank?
u = find_in_state :first, :active, :conditions => ["email = ? OR login = ?",login,login] # need to get the salt
u && u.authenticated?(password) ? u : nil
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment