Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
660afdf
Allow going back to the welcome step
matthinz Sep 28, 2023
9069a21
Allow going back to agreement step
matthinz Sep 29, 2023
3d65d9e
Update WelcomeController spec
matthinz Oct 2, 2023
c5ee3f8
Update AgreementController spec
matthinz Oct 2, 2023
3b8533e
Update agreement view spec
matthinz Oct 2, 2023
cb88b04
Update redo document capture feature spec
matthinz Oct 2, 2023
2010e77
Don't reset consent flag when proceeding from welcome step
matthinz Oct 3, 2023
0227ac8
Prevent accessing welcome step after completing document capture
matthinz Oct 3, 2023
e419c25
Update idv end-to-end spec
matthinz Oct 3, 2023
6cd44b8
Clean up ial2_consent_given vs idv_consent_given
matthinz Oct 4, 2023
efd55ca
Add document_capture_complete? method in idv_session
soniaconnolly Oct 5, 2023
bf2a947
Move and rename before_action that confirms that document capture is …
soniaconnolly Oct 5, 2023
d71df45
Add before action to agreement_controller, add specs, add pii_from_user
soniaconnolly Oct 5, 2023
3a45aab
Update redo_document_capture_spec.rb
matthinz Oct 6, 2023
f265ad2
Check for document_capture started as well as completed
soniaconnolly Oct 6, 2023
40b6af7
Add changes to GettingStarted
soniaconnolly Oct 6, 2023
9b3e861
Revert "Check for document_capture started as well as completed"
soniaconnolly Oct 10, 2023
8abd90a
Revert changes to getting_started for document capture not started
soniaconnolly Oct 10, 2023
4e8e344
Enable back button for hybrid handoff
soniaconnolly Oct 10, 2023
6ed0aaf
Make test controller anonymous in new idv_step_concern specs
soniaconnolly Oct 11, 2023
32a8b58
lint
soniaconnolly Oct 11, 2023
76e4573
Merge remote-tracking branch 'origin/main' into matthinz/11041-early-…
soniaconnolly Oct 12, 2023
6e60f00
Merge remote-tracking branch 'origin/main' into matthinz/11041-early-…
soniaconnolly Oct 16, 2023
b8e2d7c
Redirect from PhoneQuestion directly to DocumentCapture on 'no phone'
soniaconnolly Oct 16, 2023
a5c4f32
Add (failing) spec for confirm_hybrid_handoff needed
matthinz Oct 18, 2023
20b2411
Update app/controllers/concerns/idv_step_concern.rb
matthinz Oct 18, 2023
03315ae
Also cover the "hybrid flow unavailable" case
matthinz Oct 18, 2023
0978b0b
Clean up spec a little bit
matthinz Oct 18, 2023
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
42 changes: 16 additions & 26 deletions app/controllers/concerns/idv_step_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,29 +45,31 @@ def flow_path
end

def confirm_hybrid_handoff_needed
setup_for_redo if params[:redo]

if idv_session.skip_hybrid_handoff?
# We previously skipped hybrid handoff. Keep doing that.
idv_session.flow_path = 'standard'
if params[:redo]
idv_session.redo_document_capture = true
elsif idv_session.document_capture_complete?
redirect_to idv_ssn_url
return
end

if !FeatureManagement.idv_allow_hybrid_flow?
# When hybrid flow is unavailable, skip it.
# But don't store that we skipped it in idv_session, in case it is back to
# available when the user tries to redo document capture.
# If we previously skipped hybrid handoff, keep doing that.
# If hybrid flow is unavailable, skip it.
# But don't store that we skipped it in idv_session, in case it is back to
# available when the user tries to redo document capture.
if idv_session.skip_hybrid_handoff? || !FeatureManagement.idv_allow_hybrid_flow?
idv_session.flow_path = 'standard'
end

if idv_session.flow_path == 'standard'
redirect_to idv_document_capture_url
elsif idv_session.flow_path == 'hybrid'
redirect_to idv_link_sent_url
end
end

private

def confirm_document_capture_not_complete
return unless idv_session.document_capture_complete?

redirect_to idv_ssn_url
end

def confirm_ssn_step_complete
return if pii.present? && idv_session.ssn.present?
redirect_to prev_url
Expand Down Expand Up @@ -117,16 +119,4 @@ def extra_analytics_properties
end
extra
end

def setup_for_redo
idv_session.redo_document_capture = true

# If we previously skipped hybrid handoff for the user (because they're on a mobile
# device with a camera), skip it _again_ here.
if idv_session.skip_hybrid_handoff?
idv_session.flow_path = 'standard'
else
idv_session.flow_path = nil
end
end
end
6 changes: 5 additions & 1 deletion app/controllers/idv/agreement_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class AgreementController < ApplicationController

before_action :confirm_not_rate_limited
before_action :confirm_welcome_step_complete
before_action :confirm_agreement_needed
before_action :confirm_document_capture_not_complete

def show
analytics.idv_doc_auth_agreement_visited(**analytics_arguments)
Expand All @@ -14,6 +14,10 @@ def show
'agreement', :view,
true
)

@consent_form = Idv::ConsentForm.new(
idv_consent_given: idv_session.idv_consent_given,
)
end

def update
Expand Down
8 changes: 1 addition & 7 deletions app/controllers/idv/getting_started_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class GettingStartedController < ApplicationController
include IdvStepConcern

before_action :confirm_not_rate_limited
before_action :confirm_agreement_needed
before_action :confirm_document_capture_not_complete

def show
analytics.idv_doc_auth_getting_started_visited(**analytics_arguments)
Expand Down Expand Up @@ -75,11 +75,5 @@ def skip_to_capture
def consent_form_params
params.require(:doc_auth).permit(:idv_consent_given)
end

def confirm_agreement_needed
return unless idv_session.idv_consent_given

redirect_to idv_hybrid_handoff_url
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/idv/phone_question_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def phone_without_camera
merge(phone_with_camera: false),
)

redirect_to idv_hybrid_handoff_url
redirect_to idv_document_capture_url
end

private
Expand Down
8 changes: 1 addition & 7 deletions app/controllers/idv/welcome_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class WelcomeController < ApplicationController
include GettingStartedAbTestConcern

before_action :confirm_not_rate_limited
before_action :confirm_welcome_needed
before_action :confirm_document_capture_not_complete
before_action :maybe_redirect_for_getting_started_ab_test

def show
Expand Down Expand Up @@ -56,11 +56,5 @@ def cancel_previous_in_person_enrollments
UspsInPersonProofing::EnrollmentHelper.
cancel_stale_establishing_enrollments_for_user(current_user)
end

def confirm_welcome_needed
return unless idv_session.welcome_visited

redirect_to idv_agreement_url
end
end
end
12 changes: 7 additions & 5 deletions app/forms/idv/consent_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@ module Idv
class ConsentForm
include ActiveModel::Model

validates :idv_consent_given?,
attr_reader :idv_consent_given

validates :idv_consent_given,
acceptance: { message: proc { I18n.t('errors.doc_auth.consent_form') } }

def initialize(idv_consent_given: false)
@idv_consent_given = idv_consent_given
end

def submit(params)
@idv_consent_given = params[:idv_consent_given] == '1'

FormResponse.new(success: valid?, errors: errors)
end

def idv_consent_given?
@idv_consent_given
end
end
end
8 changes: 8 additions & 0 deletions app/services/idv/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ def add_failed_phone_step_number(phone)
failed_phone_step_numbers << phone_e164 if !failed_phone_step_numbers.include?(phone_e164)
end

def has_pii_from_user_in_flow_session
user_session.dig('idv/in_person', :pii_from_user)
end

def document_capture_complete?
pii_from_doc || has_pii_from_user_in_flow_session || verify_info_step_complete?
end

def verify_info_step_complete?
resolution_successful
end
Expand Down
3 changes: 2 additions & 1 deletion app/views/idv/agreement/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
<p><%= t('doc_auth.info.secure_account') %></p>

<%= simple_form_for(
:doc_auth,
@consent_form,
as: :doc_auth,
Comment thread
matthinz marked this conversation as resolved.
Outdated
url: url_for,
method: 'put',
html: { autocomplete: 'off', class: 'margin-top-2 margin-bottom-5 js-consent-continue-form' },
Expand Down
133 changes: 133 additions & 0 deletions spec/controllers/concerns/idv_step_concern_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,80 @@ def show
end
end

describe '#confirm_hybrid_handoff_needed' do
controller(idv_step_controller_class) do
before_action :confirm_hybrid_handoff_needed
end

before(:each) do
sign_in(user)
routes.draw do
get 'show' => 'anonymous#show'
end
end

context 'redo specified' do
it 'sets flag in idv_session' do
expect { get :show, params: { redo: true } }.to change {
idv_session.redo_document_capture
}.from(nil).to(true)
end

it 'does not redirect' do
get :show, params: { redo: true }
expect(response).to have_http_status(200)
end
end

context 'document capture complete' do
before do
idv_session.pii_from_doc = { first_name: 'Susan' }
end

it 'redirects to ssn screen' do
get :show
expect(response).to redirect_to(idv_ssn_url)
end

context 'and redo specified' do
it 'does not redirect' do
get :show, params: { redo: true }
expect(response).to have_http_status(200)
end
end
end

context 'previously skipped hybrid handoff' do
before do
idv_session.skip_hybrid_handoff = true
get :show
end

it 'sets flow_path to standard' do
expect(idv_session.flow_path).to eql('standard')
end

it 'redirects to document capture' do
expect(response).to redirect_to(idv_document_capture_url)
end
end

context 'hybrid flow not available' do
before do
allow(FeatureManagement).to receive(:idv_allow_hybrid_flow?).and_return(false)
get :show
end

it 'sets flow_path to standard' do
expect(idv_session.flow_path).to eql('standard')
end

it 'redirects to document capture' do
expect(response).to redirect_to(idv_document_capture_url)
end
end
end

describe '#confirm_idv_needed' do
controller(idv_step_controller_class) do
before_action :confirm_idv_needed
Expand Down Expand Up @@ -132,6 +206,65 @@ def show
end
end

describe '#confirm_document_capture_not_complete' do
controller(idv_step_controller_class) do
before_action :confirm_document_capture_not_complete
end

before(:each) do
sign_in(user)
routes.draw do
get 'show' => 'anonymous#show'
end
end

context 'the user has not completed document capture' do
it 'does not redirect and renders the view' do
idv_session.pii_from_doc = nil
idv_session.resolution_successful = nil

get :show

expect(response.body).to eq('Hello')
expect(response.status).to eq(200)
end
end

context 'the user has completed remote document capture but not verify_info' do
it 'redirects to the ssn step' do
idv_session.pii_from_doc = { first_name: 'Susan' }
idv_session.resolution_successful = false

get :show

expect(response).to redirect_to(idv_ssn_url)
end
end

context 'the user has completed in person document capture but not verify_info' do
it 'redirects to the ssn step' do
subject.user_session['idv/in_person'] = {}
subject.user_session['idv/in_person'][:pii_from_user] = { first_name: 'Susan' }
idv_session.resolution_successful = false

get :show

expect(response).to redirect_to(idv_ssn_url)
end
end

context 'the user has completed document capture and verify_info' do
it 'redirects to the ssn step' do
idv_session.pii_from_doc = nil
idv_session.resolution_successful = true

get :show

expect(response).to redirect_to(idv_ssn_url)
end
end
end

describe '#confirm_verify_info_step_complete' do
controller(idv_step_controller_class) do
before_action :confirm_verify_info_step_complete
Expand Down
15 changes: 13 additions & 2 deletions spec/controllers/idv/agreement_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,23 @@
end

context 'agreement already visited' do
it 'redirects to hybrid_handoff' do
it 'does not redirect to hybrid_handoff' do
allow(subject.idv_session).to receive(:idv_consent_given).and_return(true)

get :show

expect(response).to redirect_to(idv_hybrid_handoff_url)
expect(response).to render_template('idv/agreement/show')
end
end

context 'and document capture already completed' do
before do
subject.idv_session.pii_from_doc = { first_name: 'Susan' }
end

it 'redirects to ssn step' do
get :show
expect(response).to redirect_to(idv_ssn_url)
end
end
end
Expand Down
11 changes: 6 additions & 5 deletions spec/controllers/idv/getting_started_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,14 @@
)
end

context 'getting_started already visited' do
it 'redirects to hybrid_handoff' do
subject.idv_session.idv_consent_given = true
context 'document capture already completed' do
before do
subject.idv_session.pii_from_doc = { first_name: 'Susan' }
end

it 'redirects to ssn step' do
get :show

expect(response).to redirect_to(idv_hybrid_handoff_url)
expect(response).to redirect_to(idv_ssn_url)
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/idv/hybrid_handoff_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@

get :show

expect(response).to redirect_to(idv_document_capture_url)
expect(response).to render_template :show
end

it 'redirects to link_sent in hybrid flow' do
subject.idv_session.flow_path = 'hybrid'

get :show

expect(response).to redirect_to(idv_link_sent_url)
expect(response).to render_template :show
end
end

Expand Down
Loading