-
Notifications
You must be signed in to change notification settings - Fork 116
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
Allow multiple USPS confirmation codes #1661
Changes from all commits
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 |
---|---|---|
|
@@ -13,7 +13,8 @@ def create | |
idv_session.address_verification_mechanism = :usps | ||
|
||
if current_user.decorate.needs_profile_usps_verification? | ||
redirect_to account_path | ||
resend_letter | ||
redirect_to verify_come_back_later_url | ||
else | ||
redirect_to verify_review_url | ||
end | ||
|
@@ -29,5 +30,17 @@ def confirm_mail_not_spammed | |
redirect_to verify_review_path if idv_session.address_mechanism_chosen? && | ||
usps_mail_service.mail_spammed? | ||
end | ||
|
||
def resend_letter | ||
confirmation_maker = UspsConfirmationMaker.new( | ||
pii: Pii::Cacher.new(current_user, user_session).fetch, | ||
issuer: sp_session[:issuer], | ||
profile: current_user.decorate.pending_profile | ||
) | ||
confirmation_maker.perform | ||
|
||
return unless FeatureManagement.reveal_usps_code? | ||
session[:last_usps_confirmation_code] = confirmation_maker.otp | ||
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. CodeClimate is reporting this as not tested, do you think we should add test coverage? Since we expect to use this in our lower envs & development? 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'll write up a test 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. @zachmargolis: I actually found a bug writing the test (yay!) and I had to do some wacky things in the idv review controller to surface the OTP and put in the session. Mind taking another look to lmk what you think? |
||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class UspsConfirmationCode < ApplicationRecord | ||
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 am definitely not in love with this name. It is a bit confusing since we have a |
||
belongs_to :profile | ||
|
||
def self.first_with_otp(otp) | ||
find do |usps_confirmation_code| | ||
Pii::Fingerprinter.verify( | ||
Base32::Crockford.normalize(otp), | ||
usps_confirmation_code.otp_fingerprint | ||
) | ||
end | ||
end | ||
|
||
def expired? | ||
code_sent_at < Figaro.env.usps_confirmation_max_days.to_i.days.ago | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class CreateUspsConfirmationCodes < ActiveRecord::Migration[5.1] | ||
def change | ||
create_table :usps_confirmation_codes do |t| | ||
t.integer :profile_id, null: false | ||
t.string :otp_fingerprint, null: false | ||
t.datetime :code_sent_at, null: false, default: ->{ 'CURRENT_TIMESTAMP' } | ||
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. does this need to be a function? 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.
ref: rails/rails#27077 |
||
t.index :profile_id, using: :btree | ||
|
||
t.timestamps | ||
end | ||
end | ||
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.
I kept OTP prefilling by sticking the OTP in the session. It's a little bit brittle, so I also considered displaying it in flash message on the come back later screen. No problem making it work that way if we think that's better.