diff --git a/app/controllers/concerns/idv_session.rb b/app/controllers/concerns/idv_session.rb index 4f7c25c255e..6329fd9ca87 100644 --- a/app/controllers/concerns/idv_session.rb +++ b/app/controllers/concerns/idv_session.rb @@ -7,10 +7,6 @@ module IdvSession before_action :redirect_if_sp_context_needed end - def confirm_idv_applicant_created - redirect_to idv_verify_info_url if idv_session.applicant.blank? - end - def confirm_idv_needed return if effective_user.active_profile.blank? || decorated_session.requested_more_recent_verification? || diff --git a/app/controllers/concerns/idv_step_concern.rb b/app/controllers/concerns/idv_step_concern.rb index 8f3ba80ff5c..0067dc4c46d 100644 --- a/app/controllers/concerns/idv_step_concern.rb +++ b/app/controllers/concerns/idv_step_concern.rb @@ -8,9 +8,19 @@ module IdvStepConcern before_action :confirm_idv_needed end + def confirm_verify_info_step_complete + return if idv_session.verify_info_step_complete? + + if idv_session.in_person_enrollment? + redirect_to idv_in_person_verify_info_url + else + redirect_to idv_verify_info_url + end + end + def confirm_address_step_complete return if idv_session.address_step_complete? - redirect_to idv_otp_verification_path + redirect_to idv_otp_verification_url end end diff --git a/app/controllers/idv/phone_controller.rb b/app/controllers/idv/phone_controller.rb index e5c606c4735..b16f92a9126 100644 --- a/app/controllers/idv/phone_controller.rb +++ b/app/controllers/idv/phone_controller.rb @@ -1,7 +1,5 @@ module Idv class PhoneController < ApplicationController - before_action :confirm_verify_info_complete - include IdvStepConcern include StepIndicatorConcern include PhoneOtpRateLimitable @@ -9,7 +7,7 @@ class PhoneController < ApplicationController attr_reader :idv_form - before_action :confirm_idv_applicant_created + before_action :confirm_verify_info_step_complete before_action :confirm_step_needed before_action :set_idv_form @@ -55,14 +53,6 @@ def create private - def confirm_verify_info_complete - return unless IdentityConfig.store.in_person_verify_info_controller_enabled - return unless user_fully_authenticated? - return if idv_session.resolution_successful - - redirect_to idv_in_person_verify_info_url - end - def throttle @throttle ||= Throttle.new(user: current_user, throttle_type: :proof_address) end diff --git a/app/controllers/idv/review_controller.rb b/app/controllers/idv/review_controller.rb index 0912b585e79..121b1740167 100644 --- a/app/controllers/idv/review_controller.rb +++ b/app/controllers/idv/review_controller.rb @@ -6,18 +6,13 @@ class ReviewController < ApplicationController include StepIndicatorConcern include PhoneConfirmation - before_action :confirm_idv_applicant_created - before_action :confirm_idv_steps_complete + before_action :confirm_verify_info_step_complete before_action :confirm_address_step_complete before_action :confirm_current_password, only: [:create] rescue_from UspsInPersonProofing::Exception::RequestEnrollException, with: :handle_request_enroll_exception - def confirm_idv_steps_complete - return redirect_to(idv_verify_info_url) unless idv_profile_complete? - end - def confirm_current_password return if valid_password? @@ -90,14 +85,6 @@ def flash_message_content end end - def idv_profile_complete? - !!idv_session.profile_confirmation - end - - def idv_address_complete? - idv_session.address_mechanism_chosen? - end - def init_profile idv_session.create_profile_from_applicant_with_password(password) diff --git a/app/services/idv/session.rb b/app/services/idv/session.rb index 96af56f52c3..91024db8fe8 100644 --- a/app/services/idv/session.rb +++ b/app/services/idv/session.rb @@ -123,6 +123,14 @@ def user_phone_confirmation_session=(new_user_phone_confirmation_session) session[:user_phone_confirmation_session] = new_user_phone_confirmation_session.to_h end + def in_person_enrollment? + ProofingComponent.find_by(user: current_user)&.document_check == Idp::Constants::Vendors::USPS + end + + def verify_info_step_complete? + resolution_successful && profile_confirmation + end + def address_step_complete? if address_verification_mechanism == 'gpo' true @@ -188,10 +196,6 @@ def build_profile_maker(user_password) ) end - def in_person_enrollment? - ProofingComponent.find_by(user: current_user)&.document_check == Idp::Constants::Vendors::USPS - end - def threatmetrix_failed_and_needs_review? failed_and_needs_review = true ok_no_review_needed = false diff --git a/spec/controllers/concerns/idv_step_concern_spec.rb b/spec/controllers/concerns/idv_step_concern_spec.rb index 4645b505a50..e60cc8692e9 100644 --- a/spec/controllers/concerns/idv_step_concern_spec.rb +++ b/spec/controllers/concerns/idv_step_concern_spec.rb @@ -113,4 +113,57 @@ def show end end end + + describe '#confirm_verify_info_step_complete' do + controller Idv::StepController do + before_action :confirm_verify_info_step_complete + end + + before(:each) do + sign_in(user) + routes.draw do + get 'show' => 'idv/step#show' + end + end + + context 'the user has completed the verify info step' do + it 'does not redirect and renders the view' do + idv_session.profile_confirmation = true + idv_session.resolution_successful = 'phone' + + get :show + + expect(response.body).to eq('Hello') + expect(response.status).to eq(200) + end + end + + context 'the user has not completed the verify info step' do + it 'redirects to the remote verify info step' do + idv_session.profile_confirmation = nil + idv_session.resolution_successful = nil + + get :show + + expect(response).to redirect_to(idv_verify_info_url) + end + end + + context 'the user has not completed the verify info step with an in-person enrollment' do + it 'redirects to the in-person verify info step' do + idv_session.profile_confirmation = nil + idv_session.resolution_successful = nil + + ProofingComponent.find_or_create_by( + user: user, + ).update!( + document_check: Idp::Constants::Vendors::USPS, + ) + + get :show + + expect(response).to redirect_to(idv_in_person_verify_info_url) + end + end + end end diff --git a/spec/controllers/idv/phone_controller_spec.rb b/spec/controllers/idv/phone_controller_spec.rb index c91fc19a7da..8c60e77ca28 100644 --- a/spec/controllers/idv/phone_controller_spec.rb +++ b/spec/controllers/idv/phone_controller_spec.rb @@ -17,7 +17,7 @@ expect(subject).to have_actions( :before, :confirm_two_factor_authenticated, - :confirm_idv_applicant_created, + :confirm_verify_info_step_complete, ) end end diff --git a/spec/controllers/idv/review_controller_spec.rb b/spec/controllers/idv/review_controller_spec.rb index 1ed68a448d8..80e1b1a203a 100644 --- a/spec/controllers/idv/review_controller_spec.rb +++ b/spec/controllers/idv/review_controller_spec.rb @@ -19,6 +19,7 @@ service_provider: nil, ) idv_session.profile_confirmation = true + idv_session.resolution_successful = 'phone' idv_session.vendor_phone_confirmation = true idv_session.user_phone_confirmation = true idv_session.applicant = applicant.with_indifferent_access @@ -35,8 +36,8 @@ expect(subject).to have_actions( :before, :confirm_two_factor_authenticated, - :confirm_idv_applicant_created, - :confirm_idv_steps_complete, + :confirm_verify_info_step_complete, + :confirm_address_step_complete, ) end diff --git a/spec/support/controller_helper.rb b/spec/support/controller_helper.rb index d607be3fd3c..61db17ce642 100644 --- a/spec/support/controller_helper.rb +++ b/spec/support/controller_helper.rb @@ -67,6 +67,7 @@ def stub_verify_steps_one_and_two(user) ssn: '666-12-1234', }.with_indifferent_access idv_session.profile_confirmation = true + idv_session.resolution_successful = 'phone' allow(subject).to receive(:confirm_idv_applicant_created).and_return(true) allow(subject).to receive(:idv_session).and_return(idv_session) allow(subject).to receive(:user_session).and_return(user_session)