Ruby on Rails Saturday, June 29, 2013

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/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/12477cafe9750f1f8dc15d12e1a49263%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment