Class: CommandTower::Jwt::AuthenticationOutcome
- Inherits:
-
Object
- Object
- CommandTower::Jwt::AuthenticationOutcome
- Defined in:
- app/services/command_tower/jwt/authentication_outcome.rb
Overview
Narrow value object describing the result of AuthenticateUser only. This is deliberately not a platform result type — do not reuse it elsewhere.
Instance Attribute Summary collapse
-
#expires_at ⇒ Object
readonly
Returns the value of attribute expires_at.
-
#generated_token ⇒ Object
readonly
Returns the value of attribute generated_token.
-
#impersonation_session_id ⇒ Object
readonly
Returns the value of attribute impersonation_session_id.
-
#msg ⇒ Object
readonly
Returns the value of attribute msg.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
-
.failure(msg:, status: nil, user: nil) ⇒ Object
useris carried on failures so callers can distinguish a known user who is blocked (e.g. email verification required) from an unidentified caller. - .success(user:, expires_at:, generated_token: nil, impersonation_session_id: nil) ⇒ Object
Instance Method Summary collapse
- #failure? ⇒ Boolean
-
#initialize(success:, user: nil, expires_at: nil, generated_token: nil, status: nil, msg: nil, impersonation_session_id: nil) ⇒ AuthenticationOutcome
constructor
A new instance of AuthenticationOutcome.
- #success? ⇒ Boolean
Constructor Details
#initialize(success:, user: nil, expires_at: nil, generated_token: nil, status: nil, msg: nil, impersonation_session_id: nil) ⇒ AuthenticationOutcome
Returns a new instance of AuthenticationOutcome.
19 20 21 22 23 24 25 26 27 |
# File 'app/services/command_tower/jwt/authentication_outcome.rb', line 19 def initialize(success:, user: nil, expires_at: nil, generated_token: nil, status: nil, msg: nil, impersonation_session_id: nil) @success = success @user = user @expires_at = expires_at @generated_token = generated_token @status = status @msg = msg @impersonation_session_id = impersonation_session_id end |
Instance Attribute Details
#expires_at ⇒ Object (readonly)
Returns the value of attribute expires_at.
7 8 9 |
# File 'app/services/command_tower/jwt/authentication_outcome.rb', line 7 def expires_at @expires_at end |
#generated_token ⇒ Object (readonly)
Returns the value of attribute generated_token.
7 8 9 |
# File 'app/services/command_tower/jwt/authentication_outcome.rb', line 7 def generated_token @generated_token end |
#impersonation_session_id ⇒ Object (readonly)
Returns the value of attribute impersonation_session_id.
7 8 9 |
# File 'app/services/command_tower/jwt/authentication_outcome.rb', line 7 def impersonation_session_id @impersonation_session_id end |
#msg ⇒ Object (readonly)
Returns the value of attribute msg.
7 8 9 |
# File 'app/services/command_tower/jwt/authentication_outcome.rb', line 7 def msg @msg end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
7 8 9 |
# File 'app/services/command_tower/jwt/authentication_outcome.rb', line 7 def status @status end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
7 8 9 |
# File 'app/services/command_tower/jwt/authentication_outcome.rb', line 7 def user @user end |
Class Method Details
.failure(msg:, status: nil, user: nil) ⇒ Object
user is carried on failures so callers can distinguish a known user who
is blocked (e.g. email verification required) from an unidentified caller.
15 16 17 |
# File 'app/services/command_tower/jwt/authentication_outcome.rb', line 15 def self.failure(msg:, status: nil, user: nil) new(success: false, msg:, status:, user:) end |
.success(user:, expires_at:, generated_token: nil, impersonation_session_id: nil) ⇒ Object
9 10 11 |
# File 'app/services/command_tower/jwt/authentication_outcome.rb', line 9 def self.success(user:, expires_at:, generated_token: nil, impersonation_session_id: nil) new(success: true, user:, expires_at:, generated_token:, impersonation_session_id:) end |
Instance Method Details
#failure? ⇒ Boolean
33 34 35 |
# File 'app/services/command_tower/jwt/authentication_outcome.rb', line 33 def failure? !@success end |
#success? ⇒ Boolean
29 30 31 |
# File 'app/services/command_tower/jwt/authentication_outcome.rb', line 29 def success? @success end |