has_secure_password has a method authenticate to authenticate users
using bcrypt. In secure_password.rb file I found the following lines
(from github):
def authenticate(unencrypted_password)
BCrypt::Password.new(password_digest) == unencrypted_password &&
self
end
BCrypt::Password.new(password_digest) == unencrypted_password is clear.
Q1: Can anyone explain why the result of
BCrypt::Password.new(password_digest) == unencrypted_password is ANDed
with 'self'?
Q2: Since authenticate becomes an instance method of a class, for
instance,User and so an instance method of, say, object user, self must
be equal to (the current object) `user'. Am I right?
--
Posted via
http://www.ruby-forum.com/.