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
11
12
# File 'lib/clearance/password_strategies/bcrypt.rb', line 8

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

#password=(new_password) ⇒ Object



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

def password=(new_password)
  @password = new_password

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