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
20 changes: 20 additions & 0 deletions app/controllers/idv/in_person/usps_locations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,34 @@ def update
enrollment.update!(
selected_location_details: update_params.as_json,
issuer: current_sp&.issuer,
doc_auth_result: document_capture_session&.last_doc_auth_result,
)

add_proofing_component

render json: { success: true }, status: :ok
end

private

def idv_session
if user_session && current_user
@idv_session ||= Idv::Session.new(
user_session: user_session,
current_user: current_user,
service_provider: current_sp,
)
end
end

def document_capture_session
if idv_session&.document_capture_session_uuid # standard flow
DocumentCaptureSession.find_by(uuid: idv_session.document_capture_session_uuid)
else # hybrid flow
super
end
end

def proofer
@proofer ||= EnrollmentHelper.usps_proofer
end
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/sign_up/completions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ def analytics_attributes(page_occurence)
needs_completion_screen_reason: needs_completion_screen_reason,
}

if (last_enrollment = current_user.in_person_enrollments.last)
attributes[:in_person_proofing_status] = last_enrollment.status
attributes[:doc_auth_result] = last_enrollment.doc_auth_result
Comment on lines +93 to +94
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.

it'd be hepful to add in_person_proofing_status and doc_auth_result to user_registration_complete method in analytics_events.rb ?

end

if page_occurence.present? && DisposableEmailDomain.disposable?(email_domain)
attributes[:disposable_email_domain] = email_domain
end
Expand Down
4 changes: 4 additions & 0 deletions app/forms/idv/api_image_upload_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ def submit
if form_response.success?
client_response = post_images_to_client

document_capture_session.update!(
last_doc_auth_result: client_response.extra[:doc_auth_result],
)

if client_response.success?
doc_pii_response = validate_pii_from_doc(client_response)
end
Expand Down
6 changes: 6 additions & 0 deletions app/services/analytics_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5776,6 +5776,8 @@ def user_registration_cancellation(request_came_from:, **extra)
# @param [Array] sp_session_requested_attributes Attributes requested by the service provider
# @param [Boolean] in_account_creation_flow Whether user is going through account creation flow
# @param [String, nil] disposable_email_domain Disposable email domain used for registration
# @param [String, nil] in_person_proofing_status In person proofing status
# @param [String, nil] doc_auth_result The doc auth result
def user_registration_complete(
ial2:,
service_provider_name:,
Expand All @@ -5785,6 +5787,8 @@ def user_registration_complete(
sp_session_requested_attributes:,
ialmax: nil,
disposable_email_domain: nil,
in_person_proofing_status: nil,
doc_auth_result: nil,
**extra
)
track_event(
Expand All @@ -5797,6 +5801,8 @@ def user_registration_complete(
needs_completion_screen_reason:,
sp_session_requested_attributes:,
disposable_email_domain:,
in_person_proofing_status:,
doc_auth_result:,
**extra,
)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddDocAuthResultToInPersonEnrollments < ActiveRecord::Migration[7.1]
def change
add_column :in_person_enrollments, :doc_auth_result, :string
add_column :document_capture_sessions, :last_doc_auth_result, :string
end
end
4 changes: 3 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.1].define(version: 2024_06_04_173515) do
ActiveRecord::Schema[7.1].define(version: 2024_07_08_183211) do
# These are extensions that must be enabled in order to support this database
enable_extension "citext"
enable_extension "pg_stat_statements"
Expand Down Expand Up @@ -191,6 +191,7 @@
t.string "issuer"
t.datetime "cancelled_at", precision: nil
t.boolean "ocr_confirmation_pending", default: false
t.string "last_doc_auth_result"
t.index ["result_id"], name: "index_document_capture_sessions_on_result_id"
t.index ["user_id"], name: "index_document_capture_sessions_on_user_id"
t.index ["uuid"], name: "index_document_capture_sessions_on_uuid"
Expand Down Expand Up @@ -318,6 +319,7 @@
t.datetime "notification_sent_at", comment: "The time a notification was sent"
t.datetime "last_batch_claimed_at"
t.string "sponsor_id"
t.string "doc_auth_result"
t.index ["profile_id"], name: "index_in_person_enrollments_on_profile_id"
t.index ["ready_for_status_check"], name: "index_in_person_enrollments_on_ready_for_status_check", where: "(ready_for_status_check = true)"
t.index ["status_check_attempted_at"], name: "index_in_person_enrollments_on_status_check_attempted_at", where: "(status = 1)"
Expand Down
6 changes: 5 additions & 1 deletion spec/controllers/idv/image_uploads_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@
let(:back_image) { DocAuthImageFixtures.document_back_image_multipart }
let(:selfie_img) { nil }
let(:state_id_number) { 'S59397998' }
let(:user) { create(:user) }

before do
stub_sign_in(user) if user
end

describe '#create' do
subject(:action) do
post :create, params: params
end

let(:user) { create(:user) }
let!(:document_capture_session) { user.document_capture_sessions.create!(user: user) }
let(:flow_path) { 'standard' }
let(:params) do
Expand Down
17 changes: 17 additions & 0 deletions spec/controllers/idv/in_person/usps_locations_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,23 @@
end
end

context 'with failed doc_auth_result' do
before do
allow(controller).to receive(:document_capture_session).and_return(
OpenStruct.new({ last_doc_auth_result: 'Failed' }),
)
end

it 'updates the doc_auth_result in the enrollment' do
response

enrollment = user.reload.establishing_in_person_enrollment

expect(enrollment.selected_location_details).to_not be_nil
expect(enrollment.doc_auth_result).to eq('Failed')
end
end

context 'with feature disabled' do
let(:in_person_proofing_enabled) { false }

Expand Down
7 changes: 7 additions & 0 deletions spec/controllers/sign_up/completions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@
sp_session_requested_attributes: nil,
in_account_creation_flow: true,
disposable_email_domain: nil,
in_person_proofing_status: nil,
doc_auth_result: nil,
)
end

Expand Down Expand Up @@ -296,6 +298,8 @@
sp_session_requested_attributes: nil,
in_account_creation_flow: true,
disposable_email_domain: 'temporary.com',
doc_auth_result: nil,
in_person_proofing_status: nil,
)
end
end
Expand All @@ -312,6 +316,7 @@
)
stub_sign_in(user)
sp = create(:service_provider, issuer: 'https://awesome')
create(:in_person_enrollment, status: 'passed', doc_auth_result: 'Passed', user: user)
subject.session[:sp] = {
issuer: sp.issuer,
acr_values: Saml::Idp::Constants::IAL2_AUTHN_CONTEXT_CLASSREF,
Expand All @@ -332,6 +337,8 @@
sp_session_requested_attributes: ['email'],
in_account_creation_flow: true,
disposable_email_domain: 'temporary.com',
in_person_proofing_status: 'passed',
doc_auth_result: 'Passed',
)
end

Expand Down
16 changes: 14 additions & 2 deletions spec/forms/idv/api_image_upload_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,10 @@
DocAuth::Response.new(
success: false,
errors: errors,
extra: { remaining_submit_attempts: IdentityConfig.store.doc_auth_max_attempts - 1 },
extra: {
remaining_submit_attempts: IdentityConfig.store.doc_auth_max_attempts - 1,
doc_auth_result: 'Failed',
},
)
end
let(:doc_auth_client) { double(DocAuth::LexisNexis::LexisNexisClient) }
Expand All @@ -470,7 +473,16 @@
expect(response.selfie_status).to eq(:not_processed)
expect(response.attention_with_barcode?).to eq(false)
expect(response.pii_from_doc).to eq(nil)
end

it 'saves the doc_auth_result to document_capture_session' do
response = form.submit
session = DocumentCaptureSession.find_by(uuid: document_capture_session_uuid)

expect(response).to be_a_kind_of DocAuth::Response
expect(response.success?).to eq(false)
expect(response.doc_auth_success?).to eq(false)
expect(session.last_doc_auth_result).to eq('Failed')
end

it 'includes remaining_submit_attempts' do
Expand Down Expand Up @@ -498,7 +510,7 @@
expect(fake_analytics).to have_logged_event(
'IdV: doc auth image upload vendor submitted',
hash_including(
doc_auth_result: nil,
doc_auth_result: 'Failed',
errors: { front: 'glare' },
success: false,
doc_type_supported: boolean,
Expand Down
3 changes: 3 additions & 0 deletions spec/models/document_capture_session_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
zipcode: '12345',
issuing_country_code: 'USA',
),
extra: {
doc_auth_result: 'Passed',
},
)
end

Expand Down