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
2 changes: 1 addition & 1 deletion app/controllers/concerns/idv_step_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def confirm_document_capture_complete
def confirm_verify_info_step_complete
return if idv_session.verify_info_step_complete?

if idv_session.in_person_enrollment?
if idv_session.pending_in_person_enrollment?
redirect_to idv_in_person_verify_info_url
else
redirect_to idv_verify_info_url
Expand Down
15 changes: 12 additions & 3 deletions app/forms/gpo_verify_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ def submit

if result
pending_profile&.remove_gpo_deactivation_reason
if pending_profile&.pending_in_person_enrollment?
# note: pending_profile is not active here
pending_profile&.deactivate_for_in_person_verification_and_schedule_enrollment(pii)

if profile_has_pending_in_person_enrollment?
schedule_in_person_enrollment_and_deactivate_profile
elsif fraud_check_failed && threatmetrix_enabled?
pending_profile&.deactivate_for_fraud_review
elsif fraud_check_failed
Expand Down Expand Up @@ -61,6 +61,15 @@ def gpo_confirmation_code
pending_profile.gpo_confirmation_codes.first_with_otp(otp)
end

def profile_has_pending_in_person_enrollment?
pending_profile&.pending_in_person_enrollment?
end

def schedule_in_person_enrollment_and_deactivate_profile
UspsInPersonProofing::EnrollmentHelper.schedule_in_person_enrollment(user, pii)
pending_profile&.deactivate_for_in_person_verification
end

def which_letter
return if !valid_otp?
pending_profile.gpo_confirmation_codes.sort_by(&:code_sent_at).
Expand Down
7 changes: 4 additions & 3 deletions app/models/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def activate_after_passing_in_person
fraud_rejection_at: nil,
fraud_pending_reason: nil,
deactivation_reason: nil,
in_person_verification_pending_at: nil,
)
activate
end
Expand Down Expand Up @@ -152,10 +153,10 @@ def in_person_verification_pending?
deactivation_reason == 'in_person_verification_pending'
end

def deactivate_for_in_person_verification_and_schedule_enrollment(pii)
def deactivate_for_in_person_verification
transaction do
UspsInPersonProofing::EnrollmentHelper.schedule_in_person_enrollment(user, pii)
deactivate(:in_person_verification_pending)
deactivate(:in_person_verification_pending) # to be deprecated
update!(active: false, in_person_verification_pending_at: Time.zone.now)
end
end

Expand Down
10 changes: 3 additions & 7 deletions app/services/idv/profile_maker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,23 @@ def initialize(
applicant:,
user:,
user_password:,
initiating_service_provider: nil,
in_person_verification_pending: false
initiating_service_provider: nil
)
self.pii_attributes = Pii::Attributes.new_from_hash(applicant)
self.user = user
self.user_password = user_password
self.initiating_service_provider = initiating_service_provider
self.in_person_verification_pending = in_person_verification_pending
end

def save_profile(
fraud_pending_reason:,
gpo_verification_needed:,
in_person_verification_needed:,
deactivation_reason: nil
)
profile = Profile.new(user: user, active: false, deactivation_reason: deactivation_reason)
profile.initiating_service_provider = initiating_service_provider
if in_person_verification_pending
profile.deactivation_reason = :in_person_verification_pending
end
profile.deactivate_for_in_person_verification if in_person_verification_needed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

profile.encrypt_pii(pii_attributes, user_password)
profile.proofing_components = current_proofing_components
profile.fraud_pending_reason = fraud_pending_reason
Expand All @@ -48,7 +45,6 @@ def current_proofing_components
:user_password,
:phone_confirmed,
:initiating_service_provider,
:in_person_verification_pending,
)
attr_writer :pii_attributes
end
Expand Down
8 changes: 4 additions & 4 deletions app/services/idv/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def create_profile_from_applicant_with_password(user_password)
profile = profile_maker.save_profile(
fraud_pending_reason: threatmetrix_fraud_pending_reason,
gpo_verification_needed: gpo_verification_needed?,
in_person_verification_needed: pending_in_person_enrollment?,
)

profile.activate unless profile.reason_not_to_activate
Expand All @@ -71,7 +72,7 @@ def create_profile_from_applicant_with_password(user_password)
move_pii_to_user_session
elsif address_verification_mechanism == 'gpo'
create_gpo_entry
elsif in_person_enrollment?
elsif pending_in_person_enrollment?
UspsInPersonProofing::EnrollmentHelper.schedule_in_person_enrollment(
current_user,
pii,
Expand Down Expand Up @@ -101,7 +102,7 @@ def clear
end

def associate_in_person_enrollment_with_profile
return unless in_person_enrollment? && current_user.establishing_in_person_enrollment
return unless pending_in_person_enrollment? && current_user.establishing_in_person_enrollment
current_user.establishing_in_person_enrollment.update(profile: profile)
end

Expand Down Expand Up @@ -137,7 +138,7 @@ def add_failed_phone_step_number(phone)
failed_phone_step_numbers << phone_e164 if !failed_phone_step_numbers.include?(phone_e164)
end

def in_person_enrollment?
def pending_in_person_enrollment?
current_user.proofing_component&.document_check == Idp::Constants::Vendors::USPS
end

Expand Down Expand Up @@ -237,7 +238,6 @@ def build_profile_maker(user_password)
user: current_user,
user_password: user_password,
initiating_service_provider: service_provider,
in_person_verification_pending: in_person_enrollment?,
)
end

Expand Down
1 change: 1 addition & 0 deletions spec/controllers/idv/personal_key_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def stub_idv_session
profile = profile_maker.save_profile(
fraud_pending_reason: nil,
gpo_verification_needed: false,
in_person_verification_needed: false,
)
idv_session.pii = profile_maker.pii_attributes
idv_session.profile_id = profile.id
Expand Down
1 change: 1 addition & 0 deletions spec/factories/profiles.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

trait :in_person_verification_pending do
deactivation_reason { :in_person_verification_pending }
in_person_verification_pending_at { 15.days.ago }
end

trait :fraud_pending_reason do
Expand Down
Loading