Module: Clearance::PasswordStrategies::Argon2

Defined in:
lib/clearance/password_strategies/argon2.rb

Overview

Uses Argon2 to authenticate users and store encrypted passwords.

Instance Method Summary collapse

Instance Method Details

#authenticated?(password) ⇒ Boolean

Returns:

  • (Boolean)

8
9
10
11
12
# File 'lib/clearance/password_strategies/argon2.rb', line 8

def authenticated?(password)
  if encrypted_password.present?
    ::Argon2::Password.verify_password(password, encrypted_password)
  end
end

#password=(new_password) ⇒ Object


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

def password=(new_password)
  @password = new_password

  if new_password.present?
    self.encrypted_password = ::Argon2::Password.new.create(new_password)
  end
end