Class: WorkOS::AuthenticationResponse
- Inherits:
-
Object
- Object
- WorkOS::AuthenticationResponse
- Includes:
- HashProvider
- Defined in:
- lib/workos/authentication_response.rb
Overview
The AuthenticationResponse class represents an Authentication Response as well as an corresponding response data that can later be appended on.
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#authentication_method ⇒ Object
Returns the value of attribute authentication_method.
-
#impersonator ⇒ Object
Returns the value of attribute impersonator.
-
#organization_id ⇒ Object
Returns the value of attribute organization_id.
-
#refresh_token ⇒ Object
Returns the value of attribute refresh_token.
-
#sealed_session ⇒ Object
Returns the value of attribute sealed_session.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(authentication_response_json, session = nil) ⇒ AuthenticationResponse
constructor
rubocop:disable Metrics/AbcSize.
-
#to_json ⇒ Object
rubocop:enable Metrics/AbcSize.
Methods included from HashProvider
Constructor Details
#initialize(authentication_response_json, session = nil) ⇒ AuthenticationResponse
rubocop:disable Metrics/AbcSize
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/workos/authentication_response.rb', line 18 def initialize(authentication_response_json, session = nil) json = JSON.parse(authentication_response_json, symbolize_names: true) @access_token = json[:access_token] @refresh_token = json[:refresh_token] @user = WorkOS::User.new(json[:user].to_json) @organization_id = json[:organization_id] @impersonator = if (impersonator_json = json[:impersonator]) Impersonator.new(email: impersonator_json[:email], reason: impersonator_json[:reason],) end @authentication_method = json[:authentication_method] @sealed_session = if session && session[:seal_session] WorkOS::Session.seal_data({ access_token: access_token, refresh_token: refresh_token, user: user.to_json, organization_id: organization_id, impersonator: impersonator.to_json, }, session[:cookie_password],) end end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
9 10 11 |
# File 'lib/workos/authentication_response.rb', line 9 def access_token @access_token end |
#authentication_method ⇒ Object
Returns the value of attribute authentication_method.
9 10 11 |
# File 'lib/workos/authentication_response.rb', line 9 def authentication_method @authentication_method end |
#impersonator ⇒ Object
Returns the value of attribute impersonator.
9 10 11 |
# File 'lib/workos/authentication_response.rb', line 9 def impersonator @impersonator end |
#organization_id ⇒ Object
Returns the value of attribute organization_id.
9 10 11 |
# File 'lib/workos/authentication_response.rb', line 9 def organization_id @organization_id end |
#refresh_token ⇒ Object
Returns the value of attribute refresh_token.
9 10 11 |
# File 'lib/workos/authentication_response.rb', line 9 def refresh_token @refresh_token end |
#sealed_session ⇒ Object
Returns the value of attribute sealed_session.
9 10 11 |
# File 'lib/workos/authentication_response.rb', line 9 def sealed_session @sealed_session end |
#user ⇒ Object
Returns the value of attribute user.
9 10 11 |
# File 'lib/workos/authentication_response.rb', line 9 def user @user end |
Instance Method Details
#to_json ⇒ Object
rubocop:enable Metrics/AbcSize
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/workos/authentication_response.rb', line 43 def to_json(*) { user: user.to_json, organization_id: organization_id, impersonator: impersonator.to_json, access_token: access_token, refresh_token: refresh_token, authentication_method: authentication_method, sealed_session: sealed_session, } end |