Class: Aikotoba::Account::Password
- Inherits:
-
Object
- Object
- Aikotoba::Account::Password
- Defined in:
- app/models/aikotoba/account/password.rb
Defined Under Namespace
Classes: Argon2
Constant Summary collapse
- LENGTH_RENGE =
Aikotoba.password_length_range
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #digest ⇒ Object
-
#initialize(value:, pepper: Aikotoba.password_pepper, algorithm_class: Argon2) ⇒ Password
constructor
A new instance of Password.
- #match?(digest:) ⇒ Boolean
Constructor Details
#initialize(value:, pepper: Aikotoba.password_pepper, algorithm_class: Argon2) ⇒ Password
Returns a new instance of Password.
7 8 9 10 11 12 13 14 15 |
# File 'app/models/aikotoba/account/password.rb', line 7 def initialize( value:, pepper: Aikotoba.password_pepper, algorithm_class: Argon2 ) @value = value @pepper = pepper @algorithm = algorithm_class.new(password: password_with_pepper(@value)) end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
17 18 19 |
# File 'app/models/aikotoba/account/password.rb', line 17 def value @value end |
Instance Method Details
#digest ⇒ Object
23 24 25 26 |
# File 'app/models/aikotoba/account/password.rb', line 23 def digest return "" if value.blank? @algorithm.generate_hash end |
#match?(digest:) ⇒ Boolean
19 20 21 |
# File 'app/models/aikotoba/account/password.rb', line 19 def match?(digest:) @algorithm.verify_password?(digest) end |