Class: WorkOS::SessionManager::AuthSuccess
- Inherits:
-
Object
- Object
- WorkOS::SessionManager::AuthSuccess
- Defined in:
- lib/workos/session_manager.rb
Overview
H04 success / failure shapes — kept minimal & frozen.
Constant Summary collapse
- RESERVED_KEYS =
[ :authenticated, :reason, :session_id, :organization_id, :role, :roles, :permissions, :entitlements, :user, :impersonator, :feature_flags ].freeze
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(authenticated:, session_id:, organization_id:, role:, roles:, permissions:, entitlements:, user:, impersonator:, feature_flags:, reason: nil, custom_claims: nil) ⇒ AuthSuccess
constructor
A new instance of AuthSuccess.
- #to_h ⇒ Object
Constructor Details
#initialize(authenticated:, session_id:, organization_id:, role:, roles:, permissions:, entitlements:, user:, impersonator:, feature_flags:, reason: nil, custom_claims: nil) ⇒ AuthSuccess
Returns a new instance of AuthSuccess.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/workos/session_manager.rb', line 47 def initialize( authenticated:, session_id:, organization_id:, role:, roles:, permissions:, entitlements:, user:, impersonator:, feature_flags:, reason: nil, custom_claims: nil ) @authenticated = authenticated @reason = reason @session_id = session_id @organization_id = organization_id @role = role @roles = roles @permissions = @entitlements = entitlements @user = user @impersonator = impersonator @feature_flags = feature_flags @custom_claims = normalize_custom_claims(custom_claims) define_custom_claim_readers(@custom_claims) end |
Instance Method Details
#[](key) ⇒ Object
67 68 69 70 71 72 |
# File 'lib/workos/session_manager.rb', line 67 def [](key) sym_key = key.to_sym return public_send(sym_key) if RESERVED_KEYS.include?(sym_key) @custom_claims[sym_key] end |
#to_h ⇒ Object
74 75 76 |
# File 'lib/workos/session_manager.rb', line 74 def to_h RESERVED_KEYS.to_h { |key| [key, public_send(key)] }.merge(@custom_claims) end |