Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions app/controllers/concerns/idv_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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? ||
Expand Down
12 changes: 11 additions & 1 deletion app/controllers/concerns/idv_step_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 1 addition & 11 deletions app/controllers/idv/phone_controller.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
module Idv
class PhoneController < ApplicationController
before_action :confirm_verify_info_complete

include IdvStepConcern
include StepIndicatorConcern
include PhoneOtpRateLimitable
include PhoneOtpSendable

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

Expand Down Expand Up @@ -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
Expand Down
15 changes: 1 addition & 14 deletions app/controllers/idv/review_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand Down Expand Up @@ -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)

Expand Down
12 changes: 8 additions & 4 deletions app/services/idv/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
53 changes: 53 additions & 0 deletions spec/controllers/concerns/idv_step_concern_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion spec/controllers/idv/phone_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions spec/controllers/idv/review_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
service_provider: nil,
)
idv_session.profile_confirmation = true
idv_session.resolution_successful = 'phone'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

silly question... does GPO flow not use this controller?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, long story here. The GPO flow does use this controller. This value, however, is not related at all to the GPO flow or the phone flow for that matter. It is a value that the Flow State Machine set starting a while back that, as best as I can tell, was a copy/paste error.

We've kept using the phone value for continuity. I've been talking with @soniaconnolly about removing resolution_successful in favor of just using profile_confirmation. That may take some work to make sure things don't break in the 50/50 state.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reference, here is where this gets set when the profile is verified. This code was copied over from the verify step in the flow state machine. You can also see where the likely typo occurred.

idv_session.vendor_phone_confirmation = true
idv_session.user_phone_confirmation = true
idv_session.applicant = applicant.with_indifferent_access
Expand All @@ -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

Expand Down
1 change: 1 addition & 0 deletions spec/support/controller_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down