public
Created

  • Download Gist
user.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.