Module: Clearance::PasswordStrategies::BCrypt

Extended by:
ActiveSupport::Concern
Included in:
Clearance::PasswordStrategies::BCryptMigrationFromSHA1::BCryptUser
Defined in:
lib/clearance/password_strategies/bcrypt.rb

Instance Method Summary collapse

Instance Method Details

#authenticated?(password) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/clearance/password_strategies/bcrypt.rb', line 8

def authenticated?(password)
  ::BCrypt::Password.new(encrypted_password) == password
end

#password=(new_password) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/clearance/password_strategies/bcrypt.rb', line 12

def password=(new_password)
  @password = new_password

  if new_password.present?
    self.encrypted_password = encrypt(new_password)
  end
end