1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Refactor SecurePassword#authenticate

This commit is contained in:
Oscar Del Ben 2012-04-24 19:03:59 +02:00
parent 71bd5096be
commit ffa974d55c

View file

@ -55,11 +55,7 @@ module ActiveModel
module InstanceMethodsOnActivation
# Returns self if the password is correct, otherwise false.
def authenticate(unencrypted_password)
if BCrypt::Password.new(password_digest) == unencrypted_password
self
else
false
end
BCrypt::Password.new(password_digest) == unencrypted_password && self
end
# Encrypts the password into the password_digest attribute.