Class: Ravelin::AuthenticationMechanisms::MagicLink
- Inherits:
-
RavelinObject
- Object
- RavelinObject
- Ravelin::AuthenticationMechanisms::MagicLink
- Defined in:
- lib/ravelin/authentication_mechanisms/magic_link.rb
Constant Summary collapse
- TRANSPORTATION_MECHANISM =
%w(email sms)
- FAILURE_REASONS =
%w(INVALID_LINK TIMEOUT INTERNAL_ERROR RATE_LIMIT BANNED_USER)
Instance Attribute Summary collapse
-
#email ⇒ Object
Returns the value of attribute email.
-
#failure_reason ⇒ Object
Returns the value of attribute failure_reason.
-
#phone_number ⇒ Object
Returns the value of attribute phone_number.
-
#success ⇒ Object
Returns the value of attribute success.
-
#transport ⇒ Object
Returns the value of attribute transport.
Instance Method Summary collapse
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
#email ⇒ Object
Returns the value of attribute email.
7 8 9 |
# File 'lib/ravelin/authentication_mechanisms/magic_link.rb', line 7 def email @email end |
#failure_reason ⇒ Object
Returns the value of attribute failure_reason.
7 8 9 |
# File 'lib/ravelin/authentication_mechanisms/magic_link.rb', line 7 def failure_reason @failure_reason end |
#phone_number ⇒ Object
Returns the value of attribute phone_number.
7 8 9 |
# File 'lib/ravelin/authentication_mechanisms/magic_link.rb', line 7 def phone_number @phone_number end |
#success ⇒ Object
Returns the value of attribute success.
7 8 9 |
# File 'lib/ravelin/authentication_mechanisms/magic_link.rb', line 7 def success @success end |
#transport ⇒ Object
Returns the value of attribute transport.
7 8 9 |
# File 'lib/ravelin/authentication_mechanisms/magic_link.rb', line 7 def transport @transport end |
Instance Method Details
#validate ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ravelin/authentication_mechanisms/magic_link.rb', line 14 def validate super if !success && !FAILURE_REASONS.include?(failure_reason) raise ArgumentError.new("Failure reason value must be one of #{FAILURE_REASONS.join(', ')}") end if !TRANSPORTATION_MECHANISM.include?(transport) raise ArgumentError.new("Transportation mechanism value must be one of #{TRANSPORTATION_MECHANISM.join(', ')}") end if transport == 'email' && email.nil? raise ArgumentError.new("email must be present for email transportation mechanism") end if transport == 'sms' && phone_number.nil? raise ArgumentError.new("phone_number must be present for sms transportation mechanism") end end |