Class: CommandTower::Jwt::AuthenticationOutcome

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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_atObject (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_tokenObject (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_idObject (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

#msgObject (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

#statusObject (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

#userObject (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

Returns:

  • (Boolean)


33
34
35
# File 'app/services/command_tower/jwt/authentication_outcome.rb', line 33

def failure?
  !@success
end

#success?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'app/services/command_tower/jwt/authentication_outcome.rb', line 29

def success?
  @success
end