Class: Ravelin::Password
- Inherits:
-
RavelinObject
- Object
- RavelinObject
- Ravelin::Password
- Defined in:
- lib/ravelin/password.rb
Constant Summary collapse
- FAILURE_REASONS =
%w(BAD_PASSWORD UNKNOWN_USERNAME INTERNAL_ERROR RATE_LIMIT)
Instance Attribute Summary collapse
-
#failure_reason ⇒ Object
Returns the value of attribute failure_reason.
-
#password_hashed ⇒ Object
Returns the value of attribute password_hashed.
-
#success ⇒ Object
Returns the value of attribute success.
Instance Method Summary collapse
-
#password=(passwd) ⇒ Object
Alternative interface, because when the attr is called “password_hashed”, the end user might think they need to hash the password themselves.
- #validate ⇒ Object
Methods inherited from RavelinObject
attr_accessor, attr_required, #initialize, required_attributes, #serializable_hash
Constructor Details
This class inherits a constructor from Ravelin::RavelinObject
Instance Attribute Details
#failure_reason ⇒ Object
Returns the value of attribute failure_reason.
5 6 7 |
# File 'lib/ravelin/password.rb', line 5 def failure_reason @failure_reason end |
#password_hashed ⇒ Object
Returns the value of attribute password_hashed.
5 6 7 |
# File 'lib/ravelin/password.rb', line 5 def password_hashed @password_hashed end |
#success ⇒ Object
Returns the value of attribute success.
5 6 7 |
# File 'lib/ravelin/password.rb', line 5 def success @success end |
Instance Method Details
#password=(passwd) ⇒ Object
Alternative interface, because when the attr is called “password_hashed”, the end user might think they need to hash the password themselves
10 11 12 |
# File 'lib/ravelin/password.rb', line 10 def password=(passwd) @password_hashed = Digest::SHA256.hexdigest(passwd) end |
#validate ⇒ Object
20 21 22 23 24 25 |
# File 'lib/ravelin/password.rb', line 20 def validate super if !success && !FAILURE_REASONS.include?(failure_reason) raise ArgumentError.new("Failure reason value must be one of #{FAILURE_REASONS.join(', ')}") end end |