instance method
authenticate
Ruby on Rails 5.2.8.1
Since v3.1.12 Last seen in v5.2.8.1Signature
authenticate(unencrypted_password)
Returns self if the password is correct, otherwise false.
class User < ActiveRecord::Base has_secure_password validations: false end user = User.new(name: 'david', password: 'mUc3m00RsqyRe') user.save user.authenticate('notright') # => false user.authenticate('mUc3m00RsqyRe') # => user
Parameters
-
unencrypted_passwordreq
Source
# File activemodel/lib/active_model/secure_password.rb, line 96
def authenticate(unencrypted_password)
BCrypt::Password.new(password_digest).is_password?(unencrypted_password) && self
end
Defined in activemodel/lib/active_model/secure_password.rb line 96
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveModel::SecurePassword::InstanceMethodsOnActivation