module ActiveModel::SecurePassword::InstanceMethodsOnActivation
def authenticate(unencrypted_password)
user.authenticate('notright') # => false
user.save
user = User.new(name: 'david', password: 'mUc3m00RsqyRe')
end
has_secure_password validations: false
class User < ActiveRecord::Base
Returns +self+ if the password is correct, otherwise +false+.
def authenticate(unencrypted_password) BCrypt::Password.new(password_digest).is_password?(unencrypted_password) && self end