Class: SignIn::UserCodeMapCreator
- Inherits:
-
Object
- Object
- SignIn::UserCodeMapCreator
- Defined in:
- app/services/sign_in/user_code_map_creator.rb
Instance Attribute Summary collapse
-
#all_credential_emails ⇒ Object
readonly
Returns the value of attribute all_credential_emails.
-
#credential_email ⇒ Object
readonly
Returns the value of attribute credential_email.
-
#edipi ⇒ Object
readonly
Returns the value of attribute edipi.
-
#first_name ⇒ Object
readonly
Returns the value of attribute first_name.
-
#idme_uuid ⇒ Object
readonly
Returns the value of attribute idme_uuid.
-
#last_name ⇒ Object
readonly
Returns the value of attribute last_name.
-
#logingov_uuid ⇒ Object
readonly
Returns the value of attribute logingov_uuid.
-
#mhv_correlation_id ⇒ Object
readonly
Returns the value of attribute mhv_correlation_id.
-
#request_ip ⇒ Object
readonly
Returns the value of attribute request_ip.
-
#state_payload ⇒ Object
readonly
Returns the value of attribute state_payload.
-
#verified_icn ⇒ Object
readonly
Returns the value of attribute verified_icn.
Instance Method Summary collapse
- #access_token_attributes ⇒ Object private
- #client_config ⇒ Object private
- #create_code_container ⇒ Object private
- #create_credential_email ⇒ Object private
- #create_terms_code_container ⇒ Object private
- #create_user_acceptable_verified_credential ⇒ Object private
- #device_sso ⇒ Object private
-
#initialize(user_attributes:, state_payload:, verified_icn:, request_ip:) ⇒ UserCodeMapCreator
constructor
A new instance of UserCodeMapCreator.
- #login_code ⇒ Object private
- #needs_accepted_terms_of_use? ⇒ Boolean private
- #perform ⇒ Object
- #sign_in ⇒ Object private
- #terms_code ⇒ Object private
- #user_account ⇒ Object private
- #user_code_map ⇒ Object private
- #user_uuid ⇒ Object private
- #user_verification ⇒ Object private
- #user_verifier_object ⇒ Object private
Constructor Details
#initialize(user_attributes:, state_payload:, verified_icn:, request_ip:) ⇒ UserCodeMapCreator
Returns a new instance of UserCodeMapCreator.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/services/sign_in/user_code_map_creator.rb', line 17 def initialize(user_attributes:, state_payload:, verified_icn:, request_ip:) @state_payload = state_payload @idme_uuid = user_attributes[:idme_uuid] @logingov_uuid = user_attributes[:logingov_uuid] @credential_email = user_attributes[:csp_email] @all_credential_emails = user_attributes[:all_csp_emails] @edipi = user_attributes[:edipi] @mhv_correlation_id = user_attributes[:mhv_correlation_id] @verified_icn = verified_icn @request_ip = request_ip @first_name = user_attributes[:first_name] @last_name = user_attributes[:last_name] end |
Instance Attribute Details
#all_credential_emails ⇒ Object (readonly)
Returns the value of attribute all_credential_emails.
5 6 7 |
# File 'app/services/sign_in/user_code_map_creator.rb', line 5 def all_credential_emails @all_credential_emails end |
#credential_email ⇒ Object (readonly)
Returns the value of attribute credential_email.
5 6 7 |
# File 'app/services/sign_in/user_code_map_creator.rb', line 5 def credential_email @credential_email end |
#edipi ⇒ Object (readonly)
Returns the value of attribute edipi.
5 6 7 |
# File 'app/services/sign_in/user_code_map_creator.rb', line 5 def edipi @edipi end |
#first_name ⇒ Object (readonly)
Returns the value of attribute first_name.
5 6 7 |
# File 'app/services/sign_in/user_code_map_creator.rb', line 5 def first_name @first_name end |
#idme_uuid ⇒ Object (readonly)
Returns the value of attribute idme_uuid.
5 6 7 |
# File 'app/services/sign_in/user_code_map_creator.rb', line 5 def idme_uuid @idme_uuid end |
#last_name ⇒ Object (readonly)
Returns the value of attribute last_name.
5 6 7 |
# File 'app/services/sign_in/user_code_map_creator.rb', line 5 def last_name @last_name end |
#logingov_uuid ⇒ Object (readonly)
Returns the value of attribute logingov_uuid.
5 6 7 |
# File 'app/services/sign_in/user_code_map_creator.rb', line 5 def logingov_uuid @logingov_uuid end |
#mhv_correlation_id ⇒ Object (readonly)
Returns the value of attribute mhv_correlation_id.
5 6 7 |
# File 'app/services/sign_in/user_code_map_creator.rb', line 5 def mhv_correlation_id @mhv_correlation_id end |
#request_ip ⇒ Object (readonly)
Returns the value of attribute request_ip.
5 6 7 |
# File 'app/services/sign_in/user_code_map_creator.rb', line 5 def request_ip @request_ip end |
#state_payload ⇒ Object (readonly)
Returns the value of attribute state_payload.
5 6 7 |
# File 'app/services/sign_in/user_code_map_creator.rb', line 5 def state_payload @state_payload end |
#verified_icn ⇒ Object (readonly)
Returns the value of attribute verified_icn.
5 6 7 |
# File 'app/services/sign_in/user_code_map_creator.rb', line 5 def verified_icn @verified_icn end |
Instance Method Details
#access_token_attributes ⇒ Object (private)
106 107 108 109 110 111 |
# File 'app/services/sign_in/user_code_map_creator.rb', line 106 def access_token_attributes { first_name:, last_name:, email: credential_email, all_emails: all_credential_emails }.compact end |
#client_config ⇒ Object (private)
117 118 119 |
# File 'app/services/sign_in/user_code_map_creator.rb', line 117 def client_config @client_config ||= SignIn::ClientConfig.find_by!(client_id: state_payload.client_id) end |
#create_code_container ⇒ Object (private)
55 56 57 58 59 60 61 62 63 |
# File 'app/services/sign_in/user_code_map_creator.rb', line 55 def create_code_container CodeContainer.new(code: login_code, client_id: state_payload.client_id, code_challenge: state_payload.code_challenge, user_verification_id: user_verification.id, credential_email:, user_attributes: access_token_attributes, device_sso:).save! end |
#create_credential_email ⇒ Object (private)
42 43 44 45 |
# File 'app/services/sign_in/user_code_map_creator.rb', line 42 def create_credential_email Login::UserCredentialEmailUpdater.new(credential_email:, user_verification:).perform end |
#create_terms_code_container ⇒ Object (private)
51 52 53 |
# File 'app/services/sign_in/user_code_map_creator.rb', line 51 def create_terms_code_container TermsCodeContainer.new(code: terms_code, user_account_uuid: user_account.id).save! end |
#create_user_acceptable_verified_credential ⇒ Object (private)
47 48 49 |
# File 'app/services/sign_in/user_code_map_creator.rb', line 47 def create_user_acceptable_verified_credential Login::UserAcceptableVerifiedCredentialUpdater.new(user_account:).perform end |
#device_sso ⇒ Object (private)
65 66 67 |
# File 'app/services/sign_in/user_code_map_creator.rb', line 65 def device_sso state_payload.scope == Constants::Auth::DEVICE_SSO end |
#login_code ⇒ Object (private)
121 122 123 |
# File 'app/services/sign_in/user_code_map_creator.rb', line 121 def login_code @login_code ||= SecureRandom.uuid end |
#needs_accepted_terms_of_use? ⇒ Boolean (private)
113 114 115 |
# File 'app/services/sign_in/user_code_map_creator.rb', line 113 def needs_accepted_terms_of_use? client_config.va_terms_enforced? && user_account.needs_accepted_terms_of_use? end |
#perform ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'app/services/sign_in/user_code_map_creator.rb', line 31 def perform create_credential_email create_user_acceptable_verified_credential create_terms_code_container if needs_accepted_terms_of_use? create_code_container user_code_map end |
#sign_in ⇒ Object (private)
94 95 96 97 98 99 100 |
# File 'app/services/sign_in/user_code_map_creator.rb', line 94 def sign_in @sign_in ||= { service_name: state_payload.type, auth_broker: Constants::Auth::BROKER_CODE, client_id: state_payload.client_id } end |
#terms_code ⇒ Object (private)
125 126 127 128 129 |
# File 'app/services/sign_in/user_code_map_creator.rb', line 125 def terms_code return nil unless needs_accepted_terms_of_use? @terms_code ||= SecureRandom.uuid end |
#user_account ⇒ Object (private)
90 91 92 |
# File 'app/services/sign_in/user_code_map_creator.rb', line 90 def user_account @user_account ||= user_verification.user_account end |
#user_code_map ⇒ Object (private)
78 79 80 81 82 83 84 |
# File 'app/services/sign_in/user_code_map_creator.rb', line 78 def user_code_map @user_code_map ||= UserCodeMap.new(login_code:, type: state_payload.type, client_state: state_payload.client_state, client_config:, terms_code:) end |
#user_uuid ⇒ Object (private)
102 103 104 |
# File 'app/services/sign_in/user_code_map_creator.rb', line 102 def user_uuid @user_uuid ||= user_verification.backing_credential_identifier end |
#user_verification ⇒ Object (private)
86 87 88 |
# File 'app/services/sign_in/user_code_map_creator.rb', line 86 def user_verification @user_verification ||= Login::UserVerifier.new(user_verifier_object).perform end |
#user_verifier_object ⇒ Object (private)
69 70 71 72 73 74 75 76 |
# File 'app/services/sign_in/user_code_map_creator.rb', line 69 def user_verifier_object @user_verifier_object ||= OpenStruct.new({ idme_uuid:, logingov_uuid:, sign_in:, edipi:, mhv_correlation_id:, icn: verified_icn }) end |