-
Notifications
You must be signed in to change notification settings - Fork 167
LG-6872: Creation USPS enrollment when IPP user re-enters their password #6615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6511542
73e9d7b
bdd23ad
3069b5e
3265654
9c24677
05dd575
0d6020a
c978301
1a722ab
15c1a4c
54418f9
948968d
1a2b6e6
53b6101
1df16b0
07d69f7
c78d47e
5a7b661
ee75065
e47cdc7
20a4891
cce86be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ def create | |
| user = User.find_by(uuid: result.extra[:user_uuid]) | ||
| add_proofing_component(user) | ||
| store_session_last_gpo_code(form.gpo_code) | ||
| save_in_person_enrollment(user, form.profile) | ||
| render json: { | ||
| personal_key: personal_key, | ||
| completion_url: completion_url(result, user), | ||
|
|
@@ -59,6 +60,52 @@ def in_person_enrollment?(user) | |
| # WILLFIX: After LG-6872 and we have enrollment saved, reference enrollment instead. | ||
| ProofingComponent.find_by(user: user)&.document_check == Idp::Constants::Vendors::USPS | ||
| end | ||
|
|
||
| def usps_proofer | ||
| if IdentityConfig.store.usps_mock_fallback | ||
| UspsInPersonProofing::Mock::Proofer.new | ||
| else | ||
| UspsInPersonProofing::Proofer.new | ||
| end | ||
| end | ||
|
|
||
| def create_usps_enrollment(enrollment) | ||
| pii = user_session[:idv][:pii] | ||
| applicant = UspsInPersonProofing::Applicant.new( | ||
| { | ||
| unique_id: enrollment.usps_unique_id, | ||
| first_name: pii.first_name, | ||
| last_name: pii.last_name, | ||
| address: pii.address1, | ||
| # do we need address2? | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We do, I just didn't have time to add it in this PR. Will add in a follow-up |
||
| city: pii.city, | ||
| state: pii.state, | ||
| zip_code: pii.zipcode, | ||
| email: 'no-reply@login.gov', | ||
| }, | ||
| ) | ||
| proofer = usps_proofer | ||
|
|
||
| response = proofer.request_enroll(applicant) | ||
| response['enrollmentCode'] | ||
|
Comment on lines
+89
to
+90
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm planning on adding error handling in a follow-up PR
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WDYT of creating a Struct-like object to repesent the response here so we could do a direct property access |
||
| end | ||
|
|
||
| def save_in_person_enrollment(user, profile) | ||
| return unless in_person_enrollment?(user) | ||
|
|
||
| enrollment = InPersonEnrollment.create!( | ||
| profile: profile, | ||
| user: user, | ||
| ) | ||
|
Comment on lines
+96
to
+99
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so I had a thought I dropped in slack this morning about maybe we flip the order of these.. could be a future PR if needed! |
||
|
|
||
| enrollment_code = create_usps_enrollment(enrollment) | ||
| return unless enrollment_code | ||
|
|
||
| # update the enrollment to status pending | ||
| enrollment.enrollment_code = enrollment_code | ||
| enrollment.status = :pending | ||
| enrollment.save! | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will need error handling here too, in case there's an existing pending enrollment. |
||
| end | ||
| end | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,7 +34,7 @@ def needs_usps_status_check?(check_interval) | |
|
|
||
| # Returns the value to use for the USPS enrollment ID | ||
| def usps_unique_id | ||
| user_id.to_s | ||
| user.uuid.delete('-').slice(0, 18) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just a temporary solution. There's a separate ticket to think through the best way to generate unique IDs |
||
| end | ||
|
|
||
| private | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| module UspsInPersonProofing | ||
| Applicant = Struct.new( | ||
| :unique_id, :first_name, :last_name, :address, :city, :state, :zip_code, | ||
| :email, keyword_init: true | ||
| ) | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| module UspsInPersonProofing | ||
| module Mock | ||
| class Proofer | ||
| def request_enroll(_applicant) | ||
| JSON.load_file( | ||
| Rails.root.join('spec/fixtures/usps_ipp_responses/request_enroll_response.json'), | ||
| ) | ||
| end | ||
| end | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| module UspsInPersonProofing | ||
| PostOffice = Struct.new( | ||
| :distance, :address, :city, :phone, :name, :zip_code, :state, keyword_init: true | ||
| ) | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anything we need to think about here? I think the assumption at the time this was written was that we might create an enrollment earlier in the process.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine as-is. This method gets used twice: once before the enrollment is created and once after. The enrollment is only a useful indicator of this being an in-person flow after it is created
I'm going to leave it as-is in this file and will begin using the enrollment on the next page, in the personal key controller