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
50 changes: 38 additions & 12 deletions app/controllers/concerns/idv/verify_info_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ def process_async_state(current_async_state)

def async_state_done(current_async_state)
add_proofing_costs(current_async_state.result)

create_fraud_review_request_if_needed(current_async_state.result)

track_attempts_api_fraud_check_event_if_needed(current_async_state.result)

form_response = idv_result_to_form_response(
result: current_async_state.result,
state: pii[:state],
Expand Down Expand Up @@ -297,6 +302,33 @@ def log_idv_verification_submitted_event(success: false)
)
end

def create_fraud_review_request_if_needed(result)
return unless FeatureManagement.proofing_device_profiling_collecting_enabled?

threatmetrix_result = result.dig(:context, :stages, :threatmetrix)
return unless threatmetrix_result

return if threatmetrix_result[:review_status] == 'pass'

FraudReviewRequest.create(
user: current_user,
login_session_id: Digest::SHA1.hexdigest(current_user.unique_session_id.to_s),
)
end

def track_attempts_api_fraud_check_event_if_needed(result)
return unless FeatureManagement.proofing_device_profiling_collecting_enabled?

threatmetrix_result = result.dig(:context, :stages, :threatmetrix)
return unless threatmetrix_result

success = threatmetrix_result[:review_status] == 'pass'

irs_attempts_api_tracker.idv_tmx_fraud_check(
success: success,
)
end

def move_applicant_to_idv_session
idv_session.applicant = pii
idv_session.applicant[:ssn] = idv_session.ssn
Expand All @@ -317,24 +349,18 @@ def add_proofing_costs(results)
next if hash[:vendor_name] == 'UnsupportedJurisdiction'
# transaction_id comes from TransactionLocatorId
add_cost(:aamva, transaction_id: hash[:transaction_id])
track_aamva
elsif stage == :threatmetrix
# transaction_id comes from request_id
tmx_id = hash[:transaction_id]
log_irs_tmx_fraud_check_event(hash, current_user) if tmx_id
add_cost(:threatmetrix, transaction_id: tmx_id) if tmx_id
if hash[:transaction_id]
add_cost(
:threatmetrix,
transaction_id: hash[:transaction_id],
)
end
end
end
end

def track_aamva
return unless IdentityConfig.store.state_tracking_enabled
doc_auth_log = DocAuthLog.find_by(user_id: current_user.id)
return unless doc_auth_log
doc_auth_log.aamva = true
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.

we could prob add aamva as an ignored column to the table if we wanted?

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.

@matthinz Is the plan to follow-up with a pull request to drop the column in a separate deploy? I also noticed on Friday that the other columns in ignored_column were meant to be cleaned up last year but never were.

doc_auth_log.save!
end

def add_cost(token, transaction_id: nil)
Db::SpCost::AddSpCost.call(current_sp, token, transaction_id: transaction_id)
end
Expand Down
1 change: 1 addition & 0 deletions app/models/doc_auth_log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class DocAuthLog < ApplicationRecord

# rubocop:disable Rails/UnusedIgnoredColumns
self.ignored_columns = [
:aamva,
:email_sent_view_at,
:email_sent_view_count,
:send_link_view_at,
Expand Down
17 changes: 0 additions & 17 deletions app/services/idv/steps/threat_metrix_step_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,6 @@ def threatmetrix_iframe_url(session_id)
session_id: session_id,
)
end

def log_irs_tmx_fraud_check_event(result, user)
return unless FeatureManagement.proofing_device_profiling_collecting_enabled?

success = result[:review_status] == 'pass'

unless success
FraudReviewRequest.create(
user: user,
login_session_id: Digest::SHA1.hexdigest(user.unique_session_id.to_s),
)
end

irs_attempts_api_tracker.idv_tmx_fraud_check(
success: success,
)
end
end
end
end
4 changes: 0 additions & 4 deletions spec/features/idv/doc_auth/verify_info_step_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,6 @@

complete_ssn_step
complete_verify_step

expect(DocAuthLog.find_by(user_id: user.id).aamva).not_to be_nil
end
end

Expand All @@ -322,8 +320,6 @@

complete_ssn_step
complete_verify_step

expect(DocAuthLog.find_by(user_id: user.id).aamva).to be_nil
end
end
end
Expand Down
1 change: 0 additions & 1 deletion spec/features/idv/end_to_end_idv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ def validate_verify_info_submit(user)
expect(page).to have_content(t('doc_auth.forms.doc_success'))
expect(user.proofing_component.resolution_check).to eq(Idp::Constants::Vendors::LEXIS_NEXIS)
expect(user.proofing_component.source_check).to eq(Idp::Constants::Vendors::AAMVA)
expect(DocAuthLog.find_by(user_id: user.id).aamva).to eq(true)
end

def validate_phone_page
Expand Down