Skip to content

Instantly share code, notes, and snippets.

@zachinglis
Created December 20, 2008 22:15
Show Gist options
  • Save zachinglis/38436 to your computer and use it in GitHub Desktop.
Save zachinglis/38436 to your computer and use it in GitHub Desktop.
def self.authenticate(login, password)
return nil if login.blank? or password.blank?
# need to get the salt
if login.match("@")
user = find_in_state :first, :active, :conditions => { :email => login}
else
user = find_in_state :first, :active, :conditions => { :login => login}
end
user && user.authenticated?(password) ? user : nil
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment