Skip to content

Instantly share code, notes, and snippets.

@mokolabs
Forked from ropiku/user.rb
Created May 26, 2011 02:49
Show Gist options
  • Save mokolabs/992442 to your computer and use it in GitHub Desktop.
Save mokolabs/992442 to your computer and use it in GitHub Desktop.
If you need to support logging in via username and your usernames are case sensitive, use this.
def self.authenticate(email, password)
user = find(:first, :conditions => ['LOWER(username) = ? OR email = ?', email.to_s.downcase, email.to_s.downcase])
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