Skip to content

Instantly share code, notes, and snippets.

@zenmatt
Created April 26, 2010 16:28
Show Gist options
  • Save zenmatt/379551 to your computer and use it in GitHub Desktop.
Save zenmatt/379551 to your computer and use it in GitHub Desktop.
# Original find_for_authentication from Devise authenticatable.rb
def find_for_authentication(conditions)
find(:first, :conditions => conditions)
end
# Overwrite find_for_authentication and put it in your User model
def self.find_for_authentication(conditions={})
if conditions[:login] =~ /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i # email regex
conditions[:email] = conditions[:login]
conditions.delete("login")
end
super
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment