diff --git a/app/models/form526_submission.rb b/app/models/form526_submission.rb index 942970c946e..8ae836698ac 100644 --- a/app/models/form526_submission.rb +++ b/app/models/form526_submission.rb @@ -151,9 +151,7 @@ def submit_with_birls_id_that_hasnt_been_tried_yet!( # Note that the User record is cached in Redis -- `User.redis_namespace_ttl` def get_first_name - user = User.find(user_uuid) - user&.first_name&.upcase.presence || - auth_headers&.dig('va_eauth_firstName')&.upcase + user&.first_name&.upcase.presence || auth_headers&.dig('va_eauth_firstName')&.upcase end # Checks against the User record first, and then resorts to checking the auth_headers @@ -162,7 +160,7 @@ def get_first_name # @return [Hash] of the user's full name (first, middle, last, suffix) # def full_name - name_hash = User.find(user_uuid)&.full_name_normalized + name_hash = user&.full_name_normalized return name_hash if name_hash&.[](:first).present? { @@ -600,7 +598,6 @@ def submit_form_8940 end def submit_flashes - user = User.find(user_uuid) # Note that the User record is cached in Redis -- `User.redis_namespace_ttl` # If this method runs after the TTL, then the flashes will not be applied -- a possible bug. BGS::FlashUpdater.perform_async(id) if user && Flipper.enabled?(:disability_compensation_flashes, user) @@ -634,11 +631,15 @@ def get_past_submissions end def get_user_verifications - UserVerification.where(idme_uuid: user_uuid) - .or(UserVerification.where(backing_idme_uuid: user_uuid)) - .or(UserVerification.where(logingov_uuid: user_uuid)) - .or(UserVerification.where(mhv_uuid: user_uuid)) - .or(UserVerification.where(dslogon_uuid: user_uuid)) + UserVerification.where(idme_uuid: user&.idme_uuid) + .or(UserVerification.where(backing_idme_uuid: user&.idme_uuid)) + .or(UserVerification.where(logingov_uuid: user&.logingov_uuid)) + .or(UserVerification.where(mhv_uuid: user&.mhv_credential_uuid)) + .or(UserVerification.where(dslogon_uuid: user&.edipi)) .where.not(user_account_id:) end + + def user + @user ||= User.find(user_uuid) + end end