-
Notifications
You must be signed in to change notification settings - Fork 116
/
idv_step_concern.rb
124 lines (98 loc) · 3.59 KB
/
idv_step_concern.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
module IdvStepConcern
extend ActiveSupport::Concern
include IdvSession
include RateLimitConcern
include FraudReviewConcern
include Idv::AbTestAnalyticsConcern
included do
before_action :confirm_two_factor_authenticated
before_action :confirm_personal_key_acknowledged_if_needed
before_action :confirm_idv_needed
before_action :confirm_letter_recently_enqueued
before_action :confirm_no_pending_gpo_profile
before_action :confirm_no_pending_in_person_enrollment
before_action :handle_fraud
before_action :check_for_mail_only_outage
end
def confirm_personal_key_acknowledged_if_needed
return if !idv_session.personal_key.present?
return if idv_session.personal_key_acknowledged
# We don't give GPO users their personal key until they verify their address
return if idv_session.profile&.gpo_verification_pending?
redirect_to idv_personal_key_url
end
def confirm_letter_recently_enqueued
# idv session should be clear when user returns to enter code
return redirect_to idv_letter_enqueued_url if letter_recently_enqueued?
end
def confirm_no_pending_gpo_profile
redirect_to idv_verify_by_mail_enter_code_url if letter_not_recently_enqueued?
end
def confirm_no_pending_in_person_enrollment
return if !IdentityConfig.store.in_person_proofing_enabled
redirect_to idv_in_person_ready_to_verify_url if current_user&.pending_in_person_enrollment
end
def check_for_mail_only_outage
return if idv_session.mail_only_warning_shown
return redirect_for_mail_only if FeatureManagement.idv_by_mail_only?
end
def redirect_for_mail_only
return redirect_to vendor_outage_url unless FeatureManagement.gpo_verification_enabled?
redirect_to idv_mail_only_warning_url
end
def pii_from_user
user_session.dig('idv/in_person', 'pii_from_user')
end
def flow_path
idv_session.flow_path
end
def confirm_hybrid_handoff_needed
if params[:redo]
idv_session.redo_document_capture = true
end
# 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'
redirect_to idv_document_capture_url
end
end
private
def extra_analytics_properties
extra = {
pii_like_keypaths: [
[:same_address_as_id],
[:proofing_results, :context, :stages, :state_id, :state_id_jurisdiction],
],
}
unless flow_session.dig(:pii_from_user, :same_address_as_id).nil?
extra[:same_address_as_id] =
flow_session[:pii_from_user][:same_address_as_id].to_s == 'true'
end
extra
end
def letter_recently_enqueued?
current_user&.gpo_verification_pending_profile? &&
idv_session.verify_by_mail?
end
def letter_not_recently_enqueued?
current_user&.gpo_verification_pending_profile? &&
!idv_session.address_verification_mechanism
end
def flow_policy
@flow_policy ||= Idv::FlowPolicy.new(idv_session: idv_session, user: current_user)
end
def confirm_step_allowed
return if flow_policy.controller_allowed?(controller: self.class)
redirect_to url_for_latest_step
end
def url_for_latest_step
step_info = flow_policy.info_for_latest_step
url_for(controller: step_info.controller, action: step_info.action)
end
def clear_future_steps!
flow_policy.undo_future_steps_from_controller!(controller: self.class)
end
end