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
5 changes: 0 additions & 5 deletions app/controllers/concerns/idv/document_capture_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,5 @@ def track_document_issuing_state(user, state)
doc_auth_log.state = state
doc_auth_log.save!
end

def cancel_establishing_in_person_enrollments(user: current_user)
UspsInPersonProofing::EnrollmentHelper.
cancel_stale_establishing_enrollments_for_user(user)
end
end
end
2 changes: 0 additions & 2 deletions app/controllers/idv/document_capture_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ def update
Funnel::DocAuth::RegisterStep.new(current_user.id, sp_session[:issuer]).
call('document_capture', :update, true)

cancel_establishing_in_person_enrollments

if result.success?
redirect_to idv_ssn_url
else
Expand Down
30 changes: 30 additions & 0 deletions app/controllers/idv/socure/document_capture_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class DocumentCaptureController < ApplicationController
skip_before_action :confirm_step_allowed, only: [:update]

def show
idv_session.socure_docv_wait_polling_started_at = nil

Funnel::DocAuth::RegisterStep.new(current_user.id, sp_session[:issuer]).
call('socure_document_capture', :view, true)

Expand Down Expand Up @@ -65,6 +67,22 @@ def update
# Not used in standard flow, here for data consistency with hybrid flow.
document_capture_session.confirm_ocr

# If the stored_result is nil, the job fetching the results has not completed.
if stored_result.nil?
analytics.idv_doc_auth_document_capture_polling_wait_visited(**analytics_arguments)
if wait_timed_out?
# flash[:error] = I18n.t('errors.doc_auth.polling_timeout')
# TODO: redirect to try again page LG-14873/14952/15059
render plain: 'Technical difficulties!!!', status: :ok
else
@refresh_interval =
IdentityConfig.store.doc_auth_socure_wait_polling_refresh_max_seconds
render 'idv/socure/document_capture/wait'
end

return
end

result = handle_stored_result
# TODO: new analytics event?
analytics.idv_doc_auth_document_capture_submitted(**result.to_h.merge(analytics_arguments))
Expand Down Expand Up @@ -96,13 +114,25 @@ def self.step_info
},
undo_step: ->(idv_session:, user:) do
idv_session.pii_from_doc = nil
idv_session.socure_docv_wait_polling_started_at = nil
idv_session.invalidate_in_person_pii_from_user!
end,
)
end

private

def wait_timed_out?
if idv_session.socure_docv_wait_polling_started_at.nil?
idv_session.socure_docv_wait_polling_started_at = Time.zone.now.to_s
return false
end
start = DateTime.parse(idv_session.socure_docv_wait_polling_started_at)
timeout_period =
IdentityConfig.store.doc_auth_socure_wait_polling_timeout_minutes.minutes || 5.minutes
start + timeout_period < Time.zone.now
end

def analytics_arguments
{
flow_path: flow_path,
Expand Down
38 changes: 38 additions & 0 deletions app/services/analytics_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1240,6 +1240,44 @@ def idv_doc_auth_capture_complete_visited(
)
end

# User returns from Socure document capture, but is waiting on a result to be fetched
# @param ["hybrid","standard"] flow_path Document capture user flow
# @param [String] step Current IdV step
# @param [String] analytics_id Current IdV flow identifier
# @param [Boolean] redo_document_capture Whether user is redoing document capture after barcode
# @param [Boolean] skip_hybrid_handoff Whether skipped hybrid handoff A/B test is active
# @param [Boolean] liveness_checking_required Whether facial match check is required
# @param [Boolean] selfie_check_required Whether facial match check is required
# @param [Boolean] opted_in_to_in_person_proofing User opted into in person proofing
# @param [String] acuant_sdk_upgrade_ab_test_bucket A/B test bucket for Acuant document capture
# SDK upgrades
def idv_doc_auth_document_capture_polling_wait_visited(
flow_path:,
step:,
analytics_id:,
redo_document_capture:,
skip_hybrid_handoff:,
liveness_checking_required:,
selfie_check_required:,
opted_in_to_in_person_proofing: nil,
acuant_sdk_upgrade_ab_test_bucket: nil,
**extra
)
track_event(
:idv_doc_auth_document_capture_polling_wait_visited,
flow_path:,
step:,
analytics_id:,
redo_document_capture:,
skip_hybrid_handoff:,
liveness_checking_required:,
selfie_check_required:,
opted_in_to_in_person_proofing:,
acuant_sdk_upgrade_ab_test_bucket:,
**extra,
)
end

# User submits IdV document capture step
# @param [Boolean] success Whether form validation was successful
# @param [Hash] errors Errors resulting from form validation
Expand Down
1 change: 1 addition & 0 deletions app/services/idv/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Session
skip_doc_auth_from_handoff
skip_doc_auth_from_how_to_verify
skip_hybrid_handoff
socure_docv_wait_polling_started_at
ssn
threatmetrix_review_status
threatmetrix_session_id
Expand Down
30 changes: 30 additions & 0 deletions app/views/idv/socure/document_capture/wait.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<%= content_for(:meta_refresh) { @refresh_interval&.to_s || '15' } %>
<% self.title = t('titles.doc_auth.verify') %>
<% content_for(:pre_flash_content) do %>
<%= render StepIndicatorComponent.new(
steps: Idv::StepIndicatorConcern::STEP_INDICATOR_STEPS,
current_step: :verify_id,
locale_scope: 'idv',
class: 'margin-x-neg-2 margin-top-neg-4 tablet:margin-x-neg-6 tablet:margin-top-neg-4',
) %>
<% end %>

<%= image_tag(
asset_url('id-card.svg'),
alt: '',
width: 216,
height: 116,
class: 'margin-bottom-4',
) %>

<%= render PageHeadingComponent.new do %>
<%= t('doc_auth.headings.interstitial') %>
<% end %>

<p class='margin-top-2'>
<%= t('doc_auth.info.interstitial_eta') %>
</p>

<p>
<%= t('doc_auth.info.interstitial_thanks') %>
</p>
2 changes: 2 additions & 0 deletions config/application.yml.default
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ doc_auth_max_attempts: 5
doc_auth_max_capture_attempts_before_native_camera: 3
doc_auth_max_submission_attempts_before_native_camera: 3
doc_auth_selfie_desktop_test_mode: false
doc_auth_socure_wait_polling_refresh_max_seconds: 15
doc_auth_socure_wait_polling_timeout_minutes: 2
doc_auth_supported_country_codes: '["US", "GU", "VI", "AS", "MP", "PR", "USA" ,"GUM", "VIR", "ASM", "MNP", "PRI"]'
doc_auth_vendor: 'mock'
doc_auth_vendor_default: 'mock'
Expand Down
2 changes: 2 additions & 0 deletions lib/identity_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ def self.store
config.add(:doc_auth_max_capture_attempts_before_native_camera, type: :integer)
config.add(:doc_auth_max_submission_attempts_before_native_camera, type: :integer)
config.add(:doc_auth_selfie_desktop_test_mode, type: :boolean)
config.add(:doc_auth_socure_wait_polling_refresh_max_seconds, type: :integer)
config.add(:doc_auth_socure_wait_polling_timeout_minutes, type: :integer)
config.add(:doc_auth_supported_country_codes, type: :json)
config.add(:doc_auth_vendor, type: :string)
config.add(:doc_auth_vendor_default, type: :string)
Expand Down
13 changes: 0 additions & 13 deletions spec/controllers/idv/document_capture_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -388,19 +388,6 @@
end
end

context 'user has an establishing in-person enrollment' do
let!(:enrollment) { create(:in_person_enrollment, :establishing, user: user, profile: nil) }

it 'cancels the establishing enrollment' do
expect(user.establishing_in_person_enrollment).to eq enrollment

put :update

expect(enrollment.reload.cancelled?).to eq(true)
expect(user.reload.establishing_in_person_enrollment).to be_nil
end
end

context 'ocr confirmation pending' do
before do
subject.document_capture_session.ocr_confirmation_pending = true
Expand Down
26 changes: 26 additions & 0 deletions spec/controllers/idv/socure/document_capture_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
allow(subject).to receive(:user_session).and_return(user_session)

subject.idv_session.document_capture_session_uuid = document_capture_session.uuid

stub_analytics
end

describe '#step_info' do
Expand Down Expand Up @@ -274,6 +276,7 @@
get(:update)

expect(response).to redirect_to(idv_ssn_path)
expect(@analytics).to have_logged_event('IdV: doc auth document_capture submitted')
end

context 'when doc auth fails' do
Expand All @@ -283,6 +286,29 @@
get(:update)

expect(response).to redirect_to(idv_socure_document_capture_path)
expect(@analytics).to have_logged_event('IdV: doc auth document_capture submitted')
end
end

context 'when stored_result is nil' do
let(:stored_result) { nil }

it 'renders the wait view' do
get(:update)
expect(response).to render_template('idv/socure/document_capture/wait')
expect(@analytics).to have_logged_event(:idv_doc_auth_document_capture_polling_wait_visited)
end

context 'when the wait times out' do
before do
allow(subject).to receive(:wait_timed_out?).and_return(true)
end

it 'renders a technical difficulties message' do
get(:update)
expect(response).to have_http_status(:ok)
expect(response.body).to eq('Technical difficulties!!!')
end
end
end

Expand Down