Skip to content
Merged
6 changes: 5 additions & 1 deletion app/controllers/idv/document_capture_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ def extra_view_variables
def confirm_upload_step_complete
return if flow_session[:flow_path].present?

redirect_to idv_doc_auth_url
if IdentityConfig.store.doc_auth_hybrid_handoff_controller_enabled
redirect_to idv_hybrid_handoff_url
else
redirect_to idv_doc_auth_url
end
end

def confirm_document_capture_needed
Expand Down
34 changes: 20 additions & 14 deletions app/controllers/idv/hybrid_handoff_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ class HybridHandoffController < ApplicationController
before_action :confirm_two_factor_authenticated
before_action :render_404_if_hybrid_handoff_controller_disabled
before_action :confirm_agreement_step_complete
before_action :confirm_hybrid_handoff_needed, only: :show

def show
flow_session[:flow_path] = 'standard'
analytics.idv_doc_auth_upload_visited(**analytics_arguments)

Funnel::DocAuth::RegisterStep.new(current_user.id, sp_session[:issuer]).call(
Expand Down Expand Up @@ -62,13 +62,16 @@ def handle_phone_submission
if !failure_reason
flow_session[:flow_path] = 'hybrid'
redirect_to idv_link_sent_url

# for the 50/50 state
flow_session['Idv::Steps::UploadStep'] = true
else
redirect_to idv_hybrid_handoff_url
end

analytics.idv_doc_auth_upload_submitted(
**analytics_arguments.merge(form_response(destination: :link_sent).to_h),
)
analytics_args = analytics_arguments.merge(form_response(destination: :link_sent).to_h)
analytics_args[:flow_path] = flow_session[:flow_path]
analytics.idv_doc_auth_upload_submitted(**analytics_args)
end

def send_link
Expand Down Expand Up @@ -118,11 +121,13 @@ def bypass_send_link_steps
flow_session[:flow_path] = 'standard'
redirect_to idv_document_capture_url

# for the 50/50 state
flow_session['Idv::Steps::UploadStep'] = true

response = form_response(destination: :document_capture)
analytics.idv_doc_auth_upload_submitted(
**analytics_arguments.merge(response.to_h),
)
response
end

def extra_view_variables
Expand Down Expand Up @@ -158,18 +163,9 @@ def analytics_arguments
step: 'upload',
analytics_id: 'Doc Auth',
irs_reproofing: irs_reproofing?,
flow_path: flow_session[:flow_path],
}.merge(**acuant_sdk_ab_test_analytics_args)
end

def mark_link_sent_step_complete
flow_session['Idv::Steps::LinkSentStep'] = true
end

def mark_upload_step_complete
flow_session['Idv::Steps::UploadStep'] = true
end

def form_response(destination:)
FormResponse.new(
success: true,
Expand Down Expand Up @@ -220,6 +216,16 @@ def confirm_agreement_step_complete
redirect_to idv_doc_auth_url
end

def confirm_hybrid_handoff_needed
return if !flow_session[:flow_path]

if flow_session[:flow_path] == 'standard'
redirect_to idv_document_capture_url
elsif flow_session[:flow_path] == 'hybrid'
redirect_to idv_link_sent_url
end
end

def formatted_destination_phone
raw_phone = params.require(:doc_auth).permit(:phone)
PhoneFormatter.format(raw_phone, country_code: 'US')
Expand Down
1 change: 1 addition & 0 deletions app/controllers/idv/link_sent_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def handle_document_verification_success(get_results_response)
def render_document_capture_cancelled
if IdentityConfig.store.doc_auth_hybrid_handoff_controller_enabled
redirect_to idv_hybrid_handoff_url
flow_session[:flow_path] = nil
else
mark_upload_step_incomplete
redirect_to idv_doc_auth_url # was idv_url, why?
Expand Down
1 change: 1 addition & 0 deletions app/services/idv/actions/cancel_link_sent_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def self.analytics_submitted_event
def call
if IdentityConfig.store.doc_auth_hybrid_handoff_controller_enabled
redirect_to idv_hybrid_handoff_url
flow_session[:flow_path] = nil
else
mark_step_incomplete(:upload)
end
Expand Down
1 change: 1 addition & 0 deletions app/services/idv/actions/redo_document_capture_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def call
redirect_to idv_document_capture_url
elsif IdentityConfig.store.doc_auth_hybrid_handoff_controller_enabled
redirect_to idv_hybrid_handoff_url
flow_session[:flow_path] = nil
else
mark_step_incomplete(:upload)
end
Expand Down
4 changes: 1 addition & 3 deletions app/services/idv/steps/agreement_step.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def call

if flow_session[:skip_upload_step]
redirect_to idv_document_capture_url
flow_session[:flow_path] = 'standard'
else
redirect_to idv_hybrid_handoff_url
end
Expand All @@ -30,9 +31,6 @@ def form_submit
def skip_to_capture
# See: Idv::DocAuthController#update_if_skipping_upload
flow_session[:skip_upload_step] = true
if IdentityConfig.store.doc_auth_hybrid_handoff_controller_enabled
flow_session[:flow_path] = 'standard'
end
end

def consent_form_params
Expand Down
6 changes: 1 addition & 5 deletions spec/controllers/idv/document_capture_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
let(:flow_session) do
{ 'document_capture_session_uuid' => 'fd14e181-6fb1-4cdc-92e0-ef66dad0df4e',
:threatmetrix_session_id => 'c90ae7a5-6629-4e77-b97c-f1987c2df7d0',
:flow_path => 'standard',
'Idv::Steps::UploadStep' => true }
:flow_path => 'standard' }
end

let(:user) { create(:user) }
Expand All @@ -19,9 +18,6 @@
)
end

let(:default_sdk_version) { IdentityConfig.store.idv_acuant_sdk_version_default }
let(:alternate_sdk_version) { IdentityConfig.store.idv_acuant_sdk_version_alternate }

before do
allow(subject).to receive(:flow_session).and_return(flow_session)
stub_sign_in(user)
Expand Down
28 changes: 26 additions & 2 deletions spec/controllers/idv/hybrid_handoff_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,19 @@
:confirm_agreement_step_complete,
)
end

it 'checks that hybrid_handoff is needed' do
expect(subject).to have_actions(
:before,
:confirm_hybrid_handoff_needed,
)
end
end

describe '#show' do
let(:analytics_name) { 'IdV: doc auth upload visited' }
let(:analytics_args) do
{ flow_path: 'standard',
step: 'upload',
{ step: 'upload',
analytics_id: 'Doc Auth',
irs_reproofing: false }
end
Expand Down Expand Up @@ -68,6 +74,24 @@
expect(response).to redirect_to(idv_doc_auth_url)
end
end

context 'hybrid_handoff already visited' do
it 'redirects to document_capture in standard flow' do
subject.user_session['idv/doc_auth'][:flow_path] = 'standard'

get :show

expect(response).to redirect_to(idv_document_capture_url)
end

it 'redirects to link_sent in hybrid flow' do
subject.user_session['idv/doc_auth'][:flow_path] = 'hybrid'

get :show

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

describe '#update' do
Expand Down
8 changes: 7 additions & 1 deletion spec/features/idv/doc_auth/document_capture_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
end

it 'shows the new DocumentCapture page for desktop standard flow' do
expect(page).to have_current_path(idv_document_capture_url)
expect(page).to have_current_path(idv_document_capture_path)

expect(page).to have_content(t('doc_auth.headings.document_capture').tr(' ', ' '))
expect(page).to have_content(t('step_indicator.flows.idv.verify_id'))
Expand All @@ -48,6 +48,12 @@
irs_reproofing: false,
acuant_sdk_upgrade_ab_test_bucket: :default,
)

# it redirects here if trying to move earlier in the flow
visit(idv_doc_auth_agreement_step)
expect(page).to have_current_path(idv_document_capture_path)
visit(idv_doc_auth_upload_step)
expect(page).to have_current_path(idv_document_capture_path)
end

it 'logs return to sp link click' do
Expand Down
28 changes: 22 additions & 6 deletions spec/features/idv/doc_auth/hybrid_handoff_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

feature 'doc auth upload step' do
feature 'doc auth hybrid_handoff step' do
include IdvStepHelper
include DocAuthHelper
include ActionView::Helpers::DateHelper
Expand All @@ -19,14 +19,24 @@
allow(IdentityConfig.store).to receive(:doc_auth_hybrid_handoff_controller_enabled).
and_return(new_controller_enabled)
allow_any_instance_of(Idv::HybridHandoffController).to receive(:mobile_device?).and_return(true)
complete_doc_auth_steps_before_upload_step
allow_any_instance_of(ApplicationController).to receive(:analytics).and_return(fake_analytics)
allow_any_instance_of(ApplicationController).to receive(:irs_attempts_api_tracker).
and_return(fake_attempts_tracker)
end

context 'on a desktop device', js: true do
it 'does not skip ahead in standard desktop flow' do
visit(idv_hybrid_handoff_url)
expect(page).to have_current_path(idv_doc_auth_welcome_step)
complete_welcome_step
visit(idv_hybrid_handoff_url)
expect(page).to have_current_path(idv_doc_auth_agreement_step)
complete_agreement_step
expect(page).to have_current_path(idv_hybrid_handoff_path)
end

context 'on a desktop device' do
before do
complete_doc_auth_steps_before_upload_step
allow_any_instance_of(
Idv::HybridHandoffController,
).to receive(
Expand Down Expand Up @@ -54,9 +64,12 @@
'IdV: doc auth upload submitted',
hash_including(step: 'upload', destination: :document_capture),
)

visit(idv_hybrid_handoff_url)
expect(page).to have_current_path(idv_document_capture_path)
end

it "defaults phone to user's 2fa phone number" do
it "defaults phone to user's 2fa phone number", :js do
field = page.find_field(t('two_factor_authentication.phone_label'))
expect(field.value).to eq('(202) 555-1212')
end
Expand All @@ -73,9 +86,12 @@
'IdV: doc auth upload submitted',
hash_including(step: 'upload', destination: :link_sent),
)

visit(idv_hybrid_handoff_url)
expect(page).to have_current_path(idv_link_sent_path)
end

it 'proceeds to the next page with valid info' do
it 'proceeds to the next page with valid info', :js do
expect(fake_attempts_tracker).to receive(
:idv_phone_upload_link_sent,
).with(
Expand All @@ -96,7 +112,7 @@
expect(page).to have_current_path(idv_link_sent_path)
end

it 'does not proceed to the next page with invalid info' do
it 'does not proceed to the next page with invalid info', :js do
fill_in :doc_auth_phone, with: ''
click_send_link

Expand Down
3 changes: 1 addition & 2 deletions spec/features/idv/hybrid_mobile/hybrid_mobile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@
# Confirm that jumping to LinkSent page does not cause errors
visit idv_link_sent_url
expect(page).to have_current_path(root_url)

visit idv_hybrid_mobile_capture_complete_url
visit idv_hybrid_mobile_document_capture_url

attach_and_submit_images

Expand Down