Skip to content
6 changes: 5 additions & 1 deletion app/controllers/concerns/idv_step_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ def url_for_latest_step
end

def clear_future_steps!
flow_policy.undo_future_steps_from_controller!(controller: self.class)
clear_future_steps_from!(controller: self.class)
end

def clear_future_steps_from!(controller:)
flow_policy.undo_future_steps_from_controller!(controller: controller)
end
end
21 changes: 21 additions & 0 deletions app/controllers/idv/in_person/address_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class AddressController < ApplicationController

before_action :render_404_if_in_person_residential_address_controller_enabled_not_set
before_action :confirm_in_person_state_id_step_complete
## before_action :confirm_step_allowed # pending FSM removal of state id step
before_action :confirm_in_person_address_step_needed, only: :show

def show
Expand All @@ -15,6 +16,8 @@ def show
end

def update
# don't clear the ssn when updating address, clear after SsnController
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for leaving comment- I understand b/c we talked about this but think it will be helpful to future devs

clear_future_steps_from!(controller: Idv::InPerson::SsnController)
attrs = Idv::InPerson::AddressForm::ATTRIBUTES.difference([:same_address_as_id])
pii_from_user[:same_address_as_id] = 'false' if updating_address?
form_result = form.submit(flow_params)
Expand Down Expand Up @@ -42,6 +45,24 @@ def extra_view_variables
}
end

# update Idv::DocumentCaptureController.step_info.next_steps to include
# :ipp_address instead of :ipp_ssn in delete PR
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we talked about this but want to check that my understanding is correct. next_step should be the first non-FSM step. So currently- that is SSN. Upon delete- it will be address.

But still can't remember why not just keep it ipp_ssn b/c it is the next step in the flow

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The in person flow has DocumentCapture -> (several React steps) -> State ID -> Address (optional) -> SSN -> Verify Info. Eventually FlowPolicy will have :document_capture next_steps include :ipp_state_id when that's out of the FSM. We might need to wait to update it until then, actually, since Address is optional. It's going to take some fiddling to get all that right.

def self.step_info
Idv::StepInfo.new(
key: :ipp_address,
controller: self,
next_steps: [:ipp_ssn],
preconditions: ->(idv_session:, user:) { idv_session.ipp_state_id_complete? },
undo_step: ->(idv_session:, user:) do
flow_session[:pii_from_user][:address1] = nil
flow_session[:pii_from_user][:address2] = nil
flow_session[:pii_from_user][:city] = nil
flow_session[:pii_from_user][:zipcode] = nil
flow_session[:pii_from_user][:state] = nil
Comment on lines +57 to +61
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@svalexander, since the state_id step also sets these fields, I wonder if we shouldn't clear them here. What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think it's ok for now, especially since we're not yet including this step as a next step anywhere, so undo_step won't be called. And then if we always clear starting after SsnController for the in person steps that edit pii_from_user and ssn, it won't be a problem. But we'll have to give this more thought and see if we can come up with a better solution.

end,
)
end

private

def flow_session
Expand Down
1 change: 1 addition & 0 deletions app/policies/idv/flow_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def steps
hybrid_handoff: Idv::HybridHandoffController.step_info,
link_sent: Idv::LinkSentController.step_info,
document_capture: Idv::DocumentCaptureController.step_info,
ipp_address: Idv::InPerson::AddressController.step_info,
ssn: Idv::SsnController.step_info,
ipp_ssn: Idv::InPerson::SsnController.step_info,
verify_info: Idv::VerifyInfoController.step_info,
Expand Down
8 changes: 7 additions & 1 deletion app/services/idv/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,13 @@ def remote_document_capture_complete?
end

def ipp_document_capture_complete?
has_pii_from_user_in_flow_session
has_pii_from_user_in_flow_session &&
user_session['idv/in_person'][:pii_from_user].has_key?(:address1)
end

def ipp_state_id_complete?
has_pii_from_user_in_flow_session &&
user_session['idv/in_person'][:pii_from_user].has_key?(:identity_doc_address1)
end

def verify_info_step_complete?
Expand Down
65 changes: 35 additions & 30 deletions spec/controllers/idv/in_person/address_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
require 'rails_helper'

RSpec.describe Idv::InPerson::AddressController do
include FlowPolicyHelper
include InPersonHelper

let(:pii_from_user) { Idp::Constants::MOCK_IPP_APPLICANT_SAME_ADDRESS_AS_ID_FALSE.dup }
let(:user) { build(:user) }
let(:flow_session) do
{ pii_from_user: pii_from_user }
end
let(:ssn) { nil }

before do
allow(IdentityConfig.store).to receive(:in_person_residential_address_controller_enabled).
and_return(true)
allow(IdentityConfig.store).to receive(:usps_ipp_transliteration_enabled).
and_return(true)
allow(subject).to receive(:current_user).
and_return(user)
allow(subject).to receive(:pii_from_user).and_return(pii_from_user)
allow(subject).to receive(:flow_session).and_return(flow_session)
stub_sign_in(user)
subject.idv_session.flow_path = 'standard'
subject.idv_session.ssn = ssn
stub_up_to(:hybrid_handoff, idv_session: subject.idv_session)
subject.user_session['idv/in_person'] = {
pii_from_user: Idp::Constants::MOCK_IPP_APPLICANT_SAME_ADDRESS_AS_ID_FALSE.dup,
}
subject.idv_session.ssn = nil
stub_analytics
allow(@analytics).to receive(:track_event)
end

describe '#step_info' do
it 'returns a valid StepInfo object' do
expect(Idv::InPerson::AddressController.step_info).to be_valid
end
end

describe 'before_actions' do
context '#render_404_if_in_person_residential_address_controller_enabled not set' do
context 'flag not set' do
Expand Down Expand Up @@ -55,7 +56,7 @@

context '#confirm_in_person_state_id_step_complete' do
it 'redirects to state id page if not complete' do
flow_session[:pii_from_user].delete(:identity_doc_address1)
subject.user_session['idv/in_person'][:pii_from_user].delete(:identity_doc_address1)
get :show

expect(response).to redirect_to idv_in_person_step_url(step: :state_id)
Expand Down Expand Up @@ -99,7 +100,7 @@
end

it 'redirects to ssn page when address1 present' do
flow_session[:pii_from_user][:address1] = '123 Main St'
subject.user_session['idv/in_person'][:pii_from_user][:address1] = '123 Main St'

get :show

Expand Down Expand Up @@ -143,7 +144,6 @@
state: state,
} }
end
let(:ssn) { '900123456' }
let(:analytics_name) { 'IdV: in person proofing residential address submitted' }
let(:analytics_args) do
{
Expand All @@ -165,7 +165,7 @@
it 'sets values in the flow session' do
put :update, params: params

expect(flow_session[:pii_from_user]).to include(
expect(subject.user_session['idv/in_person'][:pii_from_user]).to include(
address1:,
address2:,
city:,
Expand All @@ -184,48 +184,53 @@

context 'when updating the residential address' do
before do
flow_session[:pii_from_user][:address1] = '123 New Residential Ave'
subject.user_session['idv/in_person'][:pii_from_user][:address1] =
'123 New Residential Ave'
end

context 'user previously selected that the residential address matched state ID' do
before do
flow_session[:pii_from_user][:same_address_as_id] = 'true'
subject.user_session['idv/in_person'][:pii_from_user][:same_address_as_id] = 'true'
end

it 'infers and sets the "same_address_as_id" in the flow session to false' do
put :update, params: params

expect(flow_session[:pii_from_user][:same_address_as_id]).to eq('false')
expect(subject.user_session['idv/in_person'][:pii_from_user][:same_address_as_id]).
to eq('false')
end
end

context 'user previously selected that the residential address did not match state ID' do
before do
flow_session[:pii_from_user][:same_address_as_id] = 'false'
subject.user_session['idv/in_person'][:pii_from_user][:same_address_as_id] = 'false'
end

it 'leaves the "same_address_as_id" in the flow session as false' do
put :update, params: params

expect(flow_session[:pii_from_user][:same_address_as_id]).to eq('false')
expect(subject.user_session['idv/in_person'][:pii_from_user][:same_address_as_id]).
to eq('false')
end
end
end

it 'invalidates future steps, but does not clear ssn' do
subject.idv_session.ssn = '123-45-6789'
expect(subject).to receive(:clear_future_steps_from!).and_call_original

expect { put :update, params: params }.not_to change { subject.idv_session.ssn }
end
end

context 'invalid address details' do
let(:address1) { '1 F@KE RD' }
let(:address2) { '@?T 1B' }
let(:city) { 'GR3AT F&LLS' }
let(:zipcode) { '59010' }
let(:state) { 'Montana' }
let(:params) do
{ in_person_address: {
address1: address1,
address2: address2,
city: city,
zipcode: zipcode,
state: state,
address1: '1 F@KE RD',
address2: '@?T 1B',
city: 'GR3AT F&LLS',
zipcode: '59010',
state: 'Montana',
} }
end
let(:analytics_name) { 'IdV: in person proofing residential address submitted' }
Expand Down
4 changes: 3 additions & 1 deletion spec/policies/idv/flow_policy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,9 @@
context 'preconditions for in_person ssn are present' do
before do
stub_up_to(:hybrid_handoff, idv_session: idv_session)
idv_session.send(:user_session)['idv/in_person'] = { pii_from_user: { pii: 'value' } }
idv_session.send(:user_session)['idv/in_person'] = {
pii_from_user: Idp::Constants::MOCK_IDV_APPLICANT_SAME_ADDRESS_AS_ID.dup,
}
end

it 'returns ipp_ssn' do
Expand Down