instance method authenticate

Ruby on Rails 4.0.13

Since v3.1.12 Last seen in v5.2.8.1

Available in: v3.1.12 v3.2.22.5 v4.0.13 v4.1.16 v4.2.9 v5.2.8.1

Signature

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_password req
Source
# File activemodel/lib/active_model/secure_password.rb, line 84
      def authenticate(unencrypted_password)
        BCrypt::Password.new(password_digest) == unencrypted_password && self
      end

Defined in activemodel/lib/active_model/secure_password.rb line 84 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveModel::SecurePassword::InstanceMethodsOnActivation

Type at least 2 characters to search.

↑↓ navigate · open · esc close