diff --git a/app/controllers/api/verify/password_confirm_controller.rb b/app/controllers/api/verify/password_confirm_controller.rb index 8f1d4a2fef7..eb3d8943d38 100644 --- a/app/controllers/api/verify/password_confirm_controller.rb +++ b/app/controllers/api/verify/password_confirm_controller.rb @@ -12,7 +12,7 @@ def create store_session_last_gpo_code(form.gpo_code) render json: { personal_key: personal_key, - completion_url: completion_url(result), + completion_url: completion_url(result, user), } else render_errors(result.errors) @@ -42,8 +42,10 @@ def add_proofing_component(user) ProofingComponent.create_or_find_by(user: user).update(verified_at: Time.zone.now) end - def completion_url(result) - if result.extra[:profile_pending] + def completion_url(result, user) + if in_person_enrollment?(user) + idv_in_person_ready_to_verify_url + elsif result.extra[:profile_pending] idv_come_back_later_url elsif current_sp sign_up_completed_url @@ -51,6 +53,12 @@ def completion_url(result) account_url end end + + def in_person_enrollment?(user) + return false unless IdentityConfig.store.in_person_proofing_enabled + # WILLFIX: After LG-6708 and we have enrollment saved, reference enrollment instead. + ProofingComponent.find_by(user: user)&.document_check == Idp::Constants::Vendors::USPS + end end end end diff --git a/app/controllers/idv/in_person/ready_to_verify_controller.rb b/app/controllers/idv/in_person/ready_to_verify_controller.rb new file mode 100644 index 00000000000..5fd76305579 --- /dev/null +++ b/app/controllers/idv/in_person/ready_to_verify_controller.rb @@ -0,0 +1,26 @@ +module Idv + module InPerson + class ReadyToVerifyController < ApplicationController + before_action :confirm_two_factor_authenticated + before_action :confirm_in_person_session + + def show + analytics.idv_in_person_ready_to_verify_visit + end + + private + + def confirm_in_person_session + redirect_to account_url unless in_person_proofing_component? + end + + def in_person_proofing_component? + proofing_component&.document_check == Idp::Constants::Vendors::USPS + end + + def proofing_component + ProofingComponent.find_by(user: current_user) + end + end + end +end diff --git a/app/controllers/idv/in_person_controller.rb b/app/controllers/idv/in_person_controller.rb index 3c9e1625c14..b91a6a415a5 100644 --- a/app/controllers/idv/in_person_controller.rb +++ b/app/controllers/idv/in_person_controller.rb @@ -7,7 +7,7 @@ class InPersonController < ApplicationController FSM_SETTINGS = { step_url: :idv_in_person_step_url, - final_url: :account_url, + final_url: :idv_phone_url, flow: Idv::Flows::InPersonFlow, analytics_id: 'In Person Proofing', }.freeze diff --git a/app/controllers/idv/personal_key_controller.rb b/app/controllers/idv/personal_key_controller.rb index 56e5a072eb8..ff848ce2600 100644 --- a/app/controllers/idv/personal_key_controller.rb +++ b/app/controllers/idv/personal_key_controller.rb @@ -33,7 +33,9 @@ def step_indicator_steps end def next_step - if session[:sp] && !pending_profile? + if in_person_enrollment? + idv_in_person_ready_to_verify_url + elsif session[:sp] && !pending_profile? sign_up_completed_url elsif pending_profile? && idv_session.address_verification_mechanism == 'gpo' idv_come_back_later_url @@ -72,6 +74,12 @@ def generate_personal_key idv_session.profile.encrypt_recovery_pii(cacher.fetch) end + def in_person_enrollment? + return false unless IdentityConfig.store.in_person_proofing_enabled + # WILLFIX: After LG-6708 and we have enrollment saved, reference enrollment instead. + ProofingComponent.find_by(user: current_user)&.document_check == Idp::Constants::Vendors::USPS + end + def pending_profile? current_user.pending_profile? end diff --git a/app/forms/idv/api_image_upload_form.rb b/app/forms/idv/api_image_upload_form.rb index c9ce06d895c..0641ff1ff98 100644 --- a/app/forms/idv/api_image_upload_form.rb +++ b/app/forms/idv/api_image_upload_form.rb @@ -227,8 +227,8 @@ def update_analytics(client_response) end def acuant_sdk_capture? - image_metadata.dig(:front, :source) == 'acuant' && - image_metadata.dig(:back, :source) == 'acuant' + image_metadata.dig(:front, :source) == Idp::Constants::Vendors::ACUANT && + image_metadata.dig(:back, :source) == Idp::Constants::Vendors::ACUANT end def image_metadata diff --git a/app/jobs/document_proofing_job.rb b/app/jobs/document_proofing_job.rb index 61e53fc16bb..d76809af2f6 100644 --- a/app/jobs/document_proofing_job.rb +++ b/app/jobs/document_proofing_job.rb @@ -134,8 +134,8 @@ def normalize_image_file(file_or_data_url) end def acuant_sdk_capture?(image_metadata) - image_metadata.dig(:front, :source) == 'acuant' && - image_metadata.dig(:back, :source) == 'acuant' + image_metadata.dig(:front, :source) == Idp::Constants::Vendors::ACUANT && + image_metadata.dig(:back, :source) == Idp::Constants::Vendors::ACUANT end def s3_helper diff --git a/app/services/analytics_events.rb b/app/services/analytics_events.rb index 9c3c35b107a..0ee0bc2b4c8 100644 --- a/app/services/analytics_events.rb +++ b/app/services/analytics_events.rb @@ -465,6 +465,11 @@ def idv_come_back_later_visit track_event('IdV: come back later visited') end + # The user visited the "ready to verify" page for the in person proofing flow + def idv_in_person_ready_to_verify_visit + track_event('IdV: in person ready to verify visited') + end + # @param [String] step_name which step the user was on # @param [Integer] remaining_attempts how many attempts the user has left before we throttle them # The user visited an error page due to an encountering an exception talking to a proofing vendor diff --git a/app/services/doc_auth_router.rb b/app/services/doc_auth_router.rb index c0eb91bfb0d..7376512bebd 100644 --- a/app/services/doc_auth_router.rb +++ b/app/services/doc_auth_router.rb @@ -153,7 +153,7 @@ def translate_generic_errors!(response) # @param [Proc,nil] warn_notifier proc takes a hash, and should log that hash to events.log def self.client(vendor_discriminator: nil, warn_notifier: nil) case doc_auth_vendor(discriminator: vendor_discriminator) - when 'acuant' + when Idp::Constants::Vendors::ACUANT DocAuthErrorTranslatorProxy.new( DocAuth::Acuant::AcuantClient.new( assure_id_password: IdentityConfig.store.acuant_assure_id_password, @@ -168,7 +168,7 @@ def self.client(vendor_discriminator: nil, warn_notifier: nil) glare_threshold: IdentityConfig.store.doc_auth_error_glare_threshold, ), ) - when 'lexisnexis' + when Idp::Constants::Vendors::LEXIS_NEXIS DocAuthErrorTranslatorProxy.new( DocAuth::LexisNexis::LexisNexisClient.new( account_id: IdentityConfig.store.lexisnexis_account_id, @@ -188,7 +188,7 @@ def self.client(vendor_discriminator: nil, warn_notifier: nil) glare_threshold: IdentityConfig.store.doc_auth_error_glare_threshold, ), ) - when 'mock' + when Idp::Constants::Vendors::MOCK DocAuthErrorTranslatorProxy.new( DocAuth::Mock::DocAuthMockClient.new( warn_notifier: warn_notifier, diff --git a/app/services/idv/steps/ipp/verify_step.rb b/app/services/idv/steps/ipp/verify_step.rb index 64660003d69..b3b11b051ce 100644 --- a/app/services/idv/steps/ipp/verify_step.rb +++ b/app/services/idv/steps/ipp/verify_step.rb @@ -3,14 +3,12 @@ module Steps module Ipp class VerifyStep < VerifyBaseStep STEP_INDICATOR_STEP = :verify_info + def call # WILLFIX: (LG-6498) make a call to Instant Verify before allowing the user to continue save_legacy_state + add_proofing_component delete_pii - - # send the user to the phone page where they'll continue the remainder of - # the idv flow - redirect_to idv_phone_url end def extra_view_variables @@ -19,6 +17,14 @@ def extra_view_variables step_url: method(:idv_in_person_step_url), } end + + private + + def add_proofing_component + ProofingComponent. + create_or_find_by(user: current_user). + update(document_check: Idp::Constants::Vendors::USPS) + end end end end diff --git a/app/views/idv/in_person/barcode.html.erb b/app/views/idv/in_person/barcode.html.erb deleted file mode 100644 index 9a780ad8d09..00000000000 --- a/app/views/idv/in_person/barcode.html.erb +++ /dev/null @@ -1,15 +0,0 @@ -<% title t('titles.doc_auth.verify') %> - -

- <%= t('in_person_proofing.headings.barcode') %> -

- -<%= validated_form_for :doc_auth, - url: url_for, - method: 'put', - html: { autocomplete: 'off', class: 'margin-y-5' } do |f| %> - <%= f.button :button, - t('doc_auth.buttons.continue'), - type: :submit, - class: 'usa-button--big usa-button--wide' %> -<% end %> diff --git a/app/views/idv/in_person/ready_to_verify/show.html.erb b/app/views/idv/in_person/ready_to_verify/show.html.erb new file mode 100644 index 00000000000..e53fb796595 --- /dev/null +++ b/app/views/idv/in_person/ready_to_verify/show.html.erb @@ -0,0 +1,3 @@ +<% title t('in_person_proofing.headings.barcode') %> + +<%= render PageHeadingComponent.new.with_content(t('in_person_proofing.headings.barcode')) %> diff --git a/config/routes.rb b/config/routes.rb index eba0b966d94..aaf5302755d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -327,6 +327,8 @@ put '/capture_doc/:step' => 'capture_doc#update' get '/in_person' => 'in_person#index' + get '/in_person/ready_to_verify' => 'in_person/ready_to_verify#show', + as: :in_person_ready_to_verify get '/in_person/:step' => 'in_person#show', as: :in_person_step put '/in_person/:step' => 'in_person#update' diff --git a/lib/idp/constants.rb b/lib/idp/constants.rb index 7ea36719bee..b334f21f698 100644 --- a/lib/idp/constants.rb +++ b/lib/idp/constants.rb @@ -1,5 +1,12 @@ module Idp module Constants + module Vendors + ACUANT = 'acuant' + LEXIS_NEXIS = 'lexisnexis' + MOCK = 'mock' + USPS = 'usps' + end + DEFAULT_IAL = 1 IAL_MAX = 0 IAL1 = 1 diff --git a/spec/controllers/api/verify/password_confirm_controller_spec.rb b/spec/controllers/api/verify/password_confirm_controller_spec.rb index 3ff27649da1..7b12242b40c 100644 --- a/spec/controllers/api/verify/password_confirm_controller_spec.rb +++ b/spec/controllers/api/verify/password_confirm_controller_spec.rb @@ -59,6 +59,21 @@ def stub_idv_session expect(response.status).to eq 400 end + context 'with in person profile' do + before do + ProofingComponent.create(user: user, document_check: Idp::Constants::Vendors::USPS) + allow(IdentityConfig.store).to receive(:in_person_proofing_enabled).and_return(true) + end + + it 'creates a profile and returns completion url' do + post :create, params: { password: password, user_bundle_token: jwt } + + expect(JSON.parse(response.body)['completion_url']).to eq( + idv_in_person_ready_to_verify_url, + ) + end + end + context 'with associated sp session' do before do session[:sp] = { issuer: create(:service_provider).issuer } diff --git a/spec/controllers/idv/in_person/ready_to_verify_controller_spec.rb b/spec/controllers/idv/in_person/ready_to_verify_controller_spec.rb new file mode 100644 index 00000000000..f34fa02fb79 --- /dev/null +++ b/spec/controllers/idv/in_person/ready_to_verify_controller_spec.rb @@ -0,0 +1,40 @@ +require 'rails_helper' + +describe Idv::InPerson::ReadyToVerifyController do + let(:user) { create(:user) } + + before do + stub_analytics + stub_sign_in(user) + end + + describe 'before_actions' do + it 'includes authentication before_action' do + expect(subject).to have_actions(:before, :confirm_two_factor_authenticated) + end + end + + describe '#show' do + subject(:response) { get :show } + + it 'redirects to account page' do + expect(response).to redirect_to account_url + end + + context 'with in person proofing component' do + before do + ProofingComponent.create(user: user, document_check: Idp::Constants::Vendors::USPS) + end + + it 'renders show template' do + expect(response).to render_template :show + end + + it 'logs analytics' do + response + + expect(@analytics).to have_logged_event('IdV: in person ready to verify visited') + end + end + end +end diff --git a/spec/controllers/idv/personal_key_controller_spec.rb b/spec/controllers/idv/personal_key_controller_spec.rb index 8c4759b2853..9475a6b99c9 100644 --- a/spec/controllers/idv/personal_key_controller_spec.rb +++ b/spec/controllers/idv/personal_key_controller_spec.rb @@ -186,5 +186,18 @@ def index expect(response).to redirect_to idv_come_back_later_path end end + + context 'with in person profile' do + before do + ProofingComponent.create(user: user, document_check: Idp::Constants::Vendors::USPS) + allow(IdentityConfig.store).to receive(:in_person_proofing_enabled).and_return(true) + end + + it 'creates a profile and returns completion url' do + patch :update + + expect(response).to redirect_to idv_in_person_ready_to_verify_url + end + end end end diff --git a/spec/features/idv/in_person_spec.rb b/spec/features/idv/in_person_spec.rb index d4e9084303c..b0d2e26090f 100644 --- a/spec/features/idv/in_person_spec.rb +++ b/spec/features/idv/in_person_spec.rb @@ -103,8 +103,8 @@ expect(page).to have_content(t('titles.idv.personal_key')) acknowledge_and_confirm_personal_key - # returns to account page - expect(page).to have_content(t('headings.account.login_info')) + # ready to verify page + expect(page).to have_content(t('in_person_proofing.headings.barcode')) end def attach_images_that_fail diff --git a/spec/services/idv/steps/ipp/verify_step_spec.rb b/spec/services/idv/steps/ipp/verify_step_spec.rb index fabb6abf606..95c1b17f47b 100644 --- a/spec/services/idv/steps/ipp/verify_step_spec.rb +++ b/spec/services/idv/steps/ipp/verify_step_spec.rb @@ -36,5 +36,11 @@ expect(flow.idv_session).to have_key 'applicant' expect(flow.idv_session['applicant']).to include(pii) end + + it 'updates proofing component vendor' do + step.call + + expect(user.proofing_component.document_check).to eq Idp::Constants::Vendors::USPS + end end end