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
6 changes: 3 additions & 3 deletions app/controllers/concerns/verify_profile_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def account_or_verify_profile_url
def account_or_verify_profile_route
return 'idv' if session[:ial2_with_no_sp_campaign] && current_user.active_profile.blank?
return 'account' unless profile_needs_verification?
return 'idv_usps' if usps_mail_bounced?
return 'idv_gpo' if gpo_mail_bounced?
'verify_account'
end

Expand All @@ -21,7 +21,7 @@ def profile_needs_verification?
current_user.decorate.pending_profile_requires_verification?
end

def usps_mail_bounced?
current_user.decorate.usps_mail_bounced?
def gpo_mail_bounced?
current_user.decorate.gpo_mail_bounced?
end
end
4 changes: 2 additions & 2 deletions app/controllers/idv/come_back_later_controller.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
module Idv
class ComeBackLaterController < ApplicationController
before_action :confirm_two_factor_authenticated
before_action :confirm_user_needs_usps_confirmation
before_action :confirm_user_needs_gpo_confirmation

def show
analytics.track_event(Analytics::IDV_COME_BACK_LATER_VISIT)
end

private

def confirm_user_needs_usps_confirmation
def confirm_user_needs_gpo_confirmation
redirect_to account_url unless current_user.decorate.pending_profile_requires_verification?
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/idv/confirmations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def download
def next_step
if session[:sp] && !pending_profile?
sign_up_completed_url
elsif pending_profile? && idv_session.address_verification_mechanism == 'usps'
elsif pending_profile? && %w[gpo usps].include?(idv_session.address_verification_mechanism)
idv_come_back_later_url
else
after_sign_in_path_for(current_user)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/idv/doc_auth_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DocAuthController < ApplicationController
}.freeze

def redirect_if_mail_bounced
redirect_to idv_usps_url if current_user.decorate.usps_mail_bounced?
redirect_to idv_gpo_url if current_user.decorate.gpo_mail_bounced?
end

def redirect_if_pending_profile
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Idv
class UspsController < ApplicationController
class GpoController < ApplicationController
include IdvSession

before_action :confirm_two_factor_authenticated
Expand All @@ -9,11 +9,11 @@ class UspsController < ApplicationController
before_action :max_attempts_reached, only: [:update]

def index
@presenter = UspsPresenter.new(current_user, url_options)
@presenter = GpoPresenter.new(current_user, url_options)
current_async_state = async_state

if current_async_state.none?
analytics.track_event(Analytics::IDV_USPS_ADDRESS_VISITED)
analytics.track_event(Analytics::IDV_GPO_ADDRESS_VISITED)
render :index
elsif current_async_state.in_progress?
render :wait
Expand All @@ -27,7 +27,7 @@ def index

def create
update_tracking
idv_session.address_verification_mechanism = :usps
idv_session.address_verification_mechanism = :gpo

if current_user.decorate.pending_profile_requires_verification?
resend_letter
Expand All @@ -40,23 +40,23 @@ def create
def update
result = idv_form.submit(profile_params)
enqueue_job if result.success?
redirect_to idv_usps_path
redirect_to idv_gpo_path
end

def usps_mail_service
@_usps_mail_service ||= Idv::UspsMail.new(current_user)
def gpo_mail_service
@_gpo_mail_service ||= Idv::GpoMail.new(current_user)
end

private

def update_tracking
analytics.track_event(Analytics::IDV_USPS_ADDRESS_LETTER_REQUESTED)
create_user_event(:usps_mail_sent, current_user)
analytics.track_event(Analytics::IDV_GPO_ADDRESS_LETTER_REQUESTED)
create_user_event(:gpo_mail_sent, current_user)
Db::ProofingComponent::Add.call(current_user.id, :address_check, 'gpo_letter')
end

def failure
redirect_to idv_usps_url unless performed?
redirect_to idv_gpo_url unless performed?
end

def pii(address_pii)
Expand All @@ -83,7 +83,7 @@ def idv_session_settings(hash)
{ 'vendor_phone_confirmation': false,
'user_phone_confirmation': false,
'resolution_successful': 'phone',
'address_verification_mechanism': 'usps',
'address_verification_mechanism': 'gpo',
'profile_confirmation': true,
'params': hash,
'applicant': hash,
Expand All @@ -92,7 +92,7 @@ def idv_session_settings(hash)

def confirm_mail_not_spammed
redirect_to idv_review_url if idv_session.address_mechanism_chosen? &&
usps_mail_service.mail_spammed?
gpo_mail_service.mail_spammed?
end

def confirm_user_completed_idv_profile_step
Expand All @@ -107,12 +107,12 @@ def confirm_user_completed_idv_profile_step
def resend_letter
confirmation_maker = confirmation_maker_perform
send_reminder
return unless FeatureManagement.reveal_usps_code?
session[:last_usps_confirmation_code] = confirmation_maker.otp
return unless FeatureManagement.reveal_gpo_code?
session[:last_gpo_confirmation_code] = confirmation_maker.otp
end

def confirmation_maker_perform
confirmation_maker = UspsConfirmationMaker.new(
confirmation_maker = GpoConfirmationMaker.new(
pii: Pii::Cacher.new(current_user, user_session).fetch,
issuer: sp_session[:issuer],
profile: current_user.decorate.pending_profile,
Expand Down Expand Up @@ -155,7 +155,7 @@ def throttle_failure

def flash_error
flash[:error] = error_message
redirect_to idv_usps_url
redirect_to idv_gpo_url
end

def max_attempts_reached
Expand All @@ -173,8 +173,8 @@ def send_reminder
end

def enqueue_job
return if idv_session.idv_usps_document_capture_session_uuid
idv_session.previous_usps_step_params = profile_params.to_h
return if idv_session.idv_gpo_document_capture_session_uuid
idv_session.previous_gpo_step_params = profile_params.to_h

document_capture_session = DocumentCaptureSession.create(
user_id: current_user.id,
Expand All @@ -184,7 +184,7 @@ def enqueue_job
)

document_capture_session.create_proofing_session
idv_session.idv_usps_document_capture_session_uuid = document_capture_session.uuid
idv_session.idv_gpo_document_capture_session_uuid = document_capture_session.uuid
applicant = pii(profile_params.to_h)
Idv::Agent.new(applicant).proof_resolution(
document_capture_session,
Expand All @@ -194,7 +194,7 @@ def enqueue_job
end

def async_state
dcs_uuid = idv_session.idv_usps_document_capture_session_uuid
dcs_uuid = idv_session.idv_gpo_document_capture_session_uuid
dcs = DocumentCaptureSession.find_by(uuid: dcs_uuid)
return ProofingSessionAsyncResult.none if dcs_uuid.nil?
return timed_out if dcs.nil?
Expand All @@ -215,18 +215,18 @@ def async_state_done(async_state)
delete_async

async_state_done_analytics(result)
applicant = pii(idv_session.previous_usps_step_params)
applicant = pii(idv_session.previous_gpo_step_params)
result.success? ? resolution_success(applicant) : failure
end

def async_state_done_analytics(result)
analytics.track_event(Analytics::IDV_USPS_ADDRESS_SUBMITTED, result.to_h)
analytics.track_event(Analytics::IDV_GPO_ADDRESS_SUBMITTED, result.to_h)
Db::SpCost::AddSpCost.call(sp_session[:issuer].to_s, 2, :lexis_nexis_resolution)
Db::ProofingCost::AddUserProofingCost.call(current_user.id, :lexis_nexis_resolution)
end

def delete_async
idv_session.idv_usps_document_capture_session_uuid = nil
idv_session.idv_gpo_document_capture_session_uuid = nil
end

def timed_out
Expand Down
11 changes: 6 additions & 5 deletions app/controllers/idv/review_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ def new
@applicant = idv_session.applicant
analytics.track_event(Analytics::IDV_REVIEW_VISIT)

usps_mail_service = Idv::UspsMail.new(current_user)
gpo_mail_service = Idv::GpoMail.new(current_user)
flash_now = flash.now
if usps_mail_service.mail_spammed?
if gpo_mail_service.mail_spammed?
flash_now[:error] = t('idv.errors.mail_limit_reached')
else
flash_now[:success] = flash_message_content
Expand All @@ -46,14 +46,15 @@ def create
redirect_to idv_confirmations_url
analytics.track_event(Analytics::IDV_REVIEW_COMPLETE)

return unless FeatureManagement.reveal_usps_code?
session[:last_usps_confirmation_code] = idv_session.usps_otp
return unless FeatureManagement.reveal_gpo_code?
session[:last_gpo_confirmation_code] = idv_session.gpo_otp
end

private

def flash_message_content
if idv_session.address_verification_mechanism == 'usps'
# NOTE: remove usps after next deploy
if %w[gpo usps].include?(idv_session.address_verification_mechanism)
t('idv.messages.mail_sent')
else
phone_of_record_msg = ActionController::Base.helpers.content_tag(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module RecurringJob
class UspsUploadController < AuthTokenController
class GpoUploadController < AuthTokenController
def create
today = Time.zone.today
UspsConfirmationUploader.new.run unless CalendarService.weekend_or_holiday?(today)
GpoConfirmationUploader.new.run unless CalendarService.weekend_or_holiday?(today)
render plain: 'ok'
end

Expand Down
6 changes: 3 additions & 3 deletions app/controllers/users/verify_account_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ class VerifyAccountController < ApplicationController

def index
analytics.track_event(Analytics::ACCOUNT_VERIFICATION_VISITED)
usps_mail = Idv::UspsMail.new(current_user)
@mail_spammed = usps_mail.mail_spammed?
gpo_mail = Idv::GpoMail.new(current_user)
@mail_spammed = gpo_mail.mail_spammed?
@verify_account_form = VerifyAccountForm.new(user: current_user)
@code = session[:last_usps_confirmation_code] if FeatureManagement.reveal_usps_code?
@code = session[:last_gpo_confirmation_code] if FeatureManagement.reveal_gpo_code?

if Throttler::IsThrottled.call(current_user.id, :verify_gpo_key)
render :throttled
Expand Down
4 changes: 2 additions & 2 deletions app/decorators/user_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ def identity_verified?
user.active_profile.present?
end

def usps_mail_bounced?
def gpo_mail_bounced?
return unless pending_profile
pending_profile&.usps_confirmation_codes&.order(created_at: :desc)&.first&.bounced_at
pending_profile&.gpo_confirmation_codes&.order(created_at: :desc)&.first&.bounced_at
end

def active_profile_newer_than_pending_profile?
Expand Down
10 changes: 5 additions & 5 deletions app/forms/verify_account_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ def pending_profile
@_pending_profile ||= user.decorate.pending_profile
end

def usps_confirmation_code
def gpo_confirmation_code
return if otp.blank? || pending_profile.blank?

pending_profile.usps_confirmation_codes.first_with_otp(otp)
pending_profile.gpo_confirmation_codes.first_with_otp(otp)
end

def validate_otp_not_expired
return unless usps_confirmation_code.present? && usps_confirmation_code.expired?
return unless gpo_confirmation_code.present? && gpo_confirmation_code.expired?

errors.add :otp, :usps_otp_expired
errors.add :otp, :gpo_otp_expired
end

def validate_pending_profile
Expand All @@ -52,7 +52,7 @@ def validate_otp
end

def valid_otp?
otp.present? && usps_confirmation_code.present?
otp.present? && gpo_confirmation_code.present?
end

def reset_sensitive_fields
Expand Down
2 changes: 1 addition & 1 deletion app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Event < ApplicationRecord
authenticator_enabled: 6,
authenticator_disabled: 7,
account_verified: 8,
usps_mail_sent: 9,
gpo_mail_sent: 9,
piv_cac_enabled: 10,
piv_cac_disabled: 11,
new_personal_key: 12,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class UspsConfirmation < ApplicationRecord
class GpoConfirmation < ApplicationRecord
self.table_name = 'usps_confirmations'

# Store the pii as encrypted json
def entry=(entry_hash)
self[:entry] = encryptor.encrypt(entry_hash.to_json)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
class UspsConfirmationCode < ApplicationRecord
class GpoConfirmationCode < ApplicationRecord
self.table_name = 'usps_confirmation_codes'

belongs_to :profile

def self.first_with_otp(otp)
find do |usps_confirmation_code|
find do |gpo_confirmation_code|
Pii::Fingerprinter.verify(
Base32::Crockford.normalize(otp),
usps_confirmation_code.otp_fingerprint,
gpo_confirmation_code.otp_fingerprint,
)
end
end
Expand Down
6 changes: 6 additions & 0 deletions app/models/letter_requests_to_gpo_ftp_log.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class LetterRequestsToGpoFtpLog < ApplicationRecord
self.table_name = 'letter_requests_to_usps_ftp_logs'

validates :ftp_at, presence: true
validates :letter_requests_count, presence: true
end
4 changes: 0 additions & 4 deletions app/models/letter_requests_to_usps_ftp_log.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/models/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class Profile < ApplicationRecord
self.ignored_columns = %w[phone_confirmed]

belongs_to :user
has_many :usps_confirmation_codes, dependent: :destroy
has_many :gpo_confirmation_codes, dependent: :destroy

validates :active, uniqueness: { scope: :user_id, if: :active? }

Expand Down
Loading