Created
April 20, 2012 04:49
-
-
Save kelhusseiny/2426082 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.authenticate(username_or_email="", login_password="") | |
if EMAIL_REGEX.match(username_or_email) | |
user = User.find_by_email(username_or_email) | |
else | |
user = User.find_by_username(username_or_email) | |
end | |
if user && user.match_password(login_password) | |
return user | |
else | |
return false | |
end | |
end | |
def match_password(login_password="") | |
encrypted_password == BCrypt::Engine.hash_secret(login_password, salt) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment