Skip to content
Closed
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
16 changes: 10 additions & 6 deletions app/controllers/idv/enter_password_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def confirm_current_password
end

def init_profile
idv_session.create_profile_from_applicant_with_password(
profile = idv_session.create_profile_from_applicant_with_password(
password,
is_enhanced_ipp: resolved_authn_context_result.enhanced_ipp?,
proofing_components: ProofingComponents.new(
Expand All @@ -137,16 +137,20 @@ def init_profile
user_session:,
).to_h,
)
if idv_session.verify_by_mail?
current_user.send_email_to_all_addresses(:verify_by_mail_letter_requested)
log_letter_enqueued_analytics(resend: false)
end

if idv_session.profile.active?
if profile.active?
create_user_event(:account_verified)
UserAlerts::AlertUserAboutAccountVerified.call(
profile: idv_session.profile,
)
elsif profile.gpo_verification_pending?
current_user.send_email_to_all_addresses(:verify_by_mail_letter_requested)
log_letter_enqueued_analytics(resend: false)
elsif profile.in_person_verification_pending?
return
elsif profile.fraud_review_pending?
# Note that IPP + GPO flows send this email later on
current_user.send_email_to_all_addresses(:idv_please_call)
end
end

Expand Down
11 changes: 5 additions & 6 deletions app/jobs/get_usps_proofing_results_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ def handle_passed_with_fraud_review_pending(enrollment, response)
)

# send email
send_please_call_email(enrollment:, visited_location_name: response['proofingPostOffice'])
send_please_call_email(enrollment:)
analytics(user: enrollment.user).
idv_in_person_usps_proofing_results_job_please_call_email_initiated(
**email_analytics_attributes(enrollment),
Expand Down Expand Up @@ -605,13 +605,12 @@ def send_failed_fraud_email(enrollment:, visited_location_name:)
end
end

def send_please_call_email(enrollment:, visited_location_name:)
def send_please_call_email(enrollment:)
enrollment.user.confirmed_email_addresses.each do |email_address|
# rubocop:disable IdentityIdp/MailLaterLinter
UserMailer.with(user: enrollment.user, email_address: email_address).in_person_please_call(
enrollment: enrollment,
visited_location_name: visited_location_name,
).deliver_later(**notification_delivery_params(enrollment))
UserMailer.with(user: enrollment.user, email_address: email_address).
idv_please_call.
deliver_later(**notification_delivery_params(enrollment))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's a minor 50/50 state risk here--if the 50/50 state persists longer than the deliver_later delay (1 hour), it's possible that an old server could pick up the job and call idv_please_call, which won't exist. However:

  • I'm only 99% sure that's how deliver_later works here (i.e. that it re-calls the mailer method later on)
  • A 50/50 state lasting that long shouldn't happen.

I can remove this and do it in a separate deploy if folks want.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm trying to wrap my head around this one. Is there any danger if we discover and issue and need to revert and go from new back to old?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is a good callout. I hadn't considered reverting. I think this ends up looking a lot like adding a new job: deliver_later schedules a job that invokes a method on the mailer. If the mailer the job has when it runs does not have the method defined, it will fail.

So I think this will be two PRs / deploys:

  1. Add new method with IPP variant as an alias
  2. Start calling it for remote unsupervised + update IPP to call it as well, remove alias

# rubocop:enable IdentityIdp/MailLaterLinter
end
end
Expand Down
29 changes: 14 additions & 15 deletions app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,20 @@ def account_verified(profile:)
end
end

def idv_please_call(**)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

** is there to support backwards compat with in_person_please_call, can be cleaned up later

with_user_locale(user) do
@hide_title = true

mail(
to: email_address.email,
subject: t('user_mailer.idv_please_call.subject', app_name: APP_NAME),
template_name: 'idv_please_call',
)
end
end

alias_method :in_person_please_call, :idv_please_call
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This alias can be cleaned up after deploy


def in_person_completion_survey
with_user_locale(user) do
@header = t('user_mailer.in_person_completion_survey.header')
Expand Down Expand Up @@ -373,21 +387,6 @@ def in_person_failed_fraud(enrollment:, visited_location_name: nil)
end
end

def in_person_please_call(enrollment:, visited_location_name: nil)
with_user_locale(user) do
@presenter = Idv::InPerson::VerificationResultsEmailPresenter.new(
enrollment: enrollment,
url_options: url_options,
visited_location_name: visited_location_name,
)
@hide_title = true
mail(
to: email_address.email,
subject: t('user_mailer.in_person_please_call.subject', app_name: APP_NAME),
)
end
end

def account_rejected
with_user_locale(user) do
mail(
Expand Down
3 changes: 3 additions & 0 deletions app/services/idv/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def respond_to_missing?(method_sym, include_private)
VALID_SESSION_ATTRIBUTES.include?(attr_name_sym) || super
end

# @return [Profile]
def create_profile_from_applicant_with_password(
user_password, is_enhanced_ipp:, proofing_components:
)
Expand Down Expand Up @@ -141,6 +142,8 @@ def create_profile_from_applicant_with_password(
if profile.gpo_verification_pending?
create_gpo_entry(profile_maker.pii_attributes, profile)
end

profile
end

def opt_in_param
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
width: 88,
height: 88,
) %>
<h1><%= t('user_mailer.in_person_please_call.header') %></h1>
<h1><%= t('user_mailer.idv_please_call.header') %></h1>
<p>
<%= t(
'user_mailer.in_person_please_call.body.intro_html',
'user_mailer.idv_please_call.body.intro_html',
date: I18n.l(14.days.from_now, format: I18n.t('time.formats.full_date')),
) %>
</p>
<p>
<%= t(
'user_mailer.in_person_please_call.body.contact_message_html',
'user_mailer.idv_please_call.body.contact_message_html',
contact_number: IdentityConfig.store.idv_contact_phone_number,
support_code: IdentityConfig.store.lexisnexis_threatmetrix_support_code,
) %>
Expand Down
8 changes: 4 additions & 4 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1867,6 +1867,10 @@ user_mailer.email_deleted.header: An email address was deleted from your %{app_n
user_mailer.email_deleted.help_html: If you did not want to delete this email address, please visit the %{app_name_html} %{help_link_html} or %{contact_link_html}.
user_mailer.email_deleted.subject: Email address deleted
user_mailer.help_link_text: Help Center
user_mailer.idv_please_call.body.contact_message_html: Call <strong>%{contact_number}</strong> and provide them with the error code <strong>%{support_code}</strong>.
user_mailer.idv_please_call.body.intro_html: Call our contact center by <strong>%{date}</strong> to continue verifying your identity.
user_mailer.idv_please_call.header: Please give us a call
user_mailer.idv_please_call.subject: Call %{app_name} to continue with your identity verification
user_mailer.in_person_completion_survey.body.cta.callout: Click the button below to get started.
user_mailer.in_person_completion_survey.body.cta.label: Take our survey
user_mailer.in_person_completion_survey.body.greeting: Hello,
Expand All @@ -1892,10 +1896,6 @@ user_mailer.in_person_failed.intro: Your identity could not be verified at the %
user_mailer.in_person_failed.subject: Your identity could not be verified in person
user_mailer.in_person_failed.verifying_identity: 'When verifying your identity:'
user_mailer.in_person_failed.verifying_step_not_expired: Your state‑issued ID or driver’s license must not be expired. We do not currently accept any other forms of identification, such as passports and military IDs.
user_mailer.in_person_please_call.body.contact_message_html: Call <strong>%{contact_number}</strong> and provide them with the error code <strong>%{support_code}</strong>.
user_mailer.in_person_please_call.body.intro_html: Call our contact center by <strong>%{date}</strong> to continue verifying your identity.
user_mailer.in_person_please_call.header: Please give us a call
user_mailer.in_person_please_call.subject: Call %{app_name} to continue with your identity verification
user_mailer.in_person_ready_to_verify_reminder.greeting: Hello,
user_mailer.in_person_ready_to_verify_reminder.heading.one: You have %{count} day left to verify your identity in person
user_mailer.in_person_ready_to_verify_reminder.heading.other: You have %{count} days left to verify your identity in person
Expand Down
8 changes: 4 additions & 4 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1879,6 +1879,10 @@ user_mailer.email_deleted.header: Se eliminó una dirección de correo electrón
user_mailer.email_deleted.help_html: Si no deseaba eliminar esta dirección de correo electrónico, visite %{help_link_html} de %{app_name_html} o %{contact_link_html}.
user_mailer.email_deleted.subject: Dirección de correo electrónico eliminada
user_mailer.help_link_text: Centro de ayuda
user_mailer.idv_please_call.body.contact_message_html: Llame al <strong>%{contact_number}</strong> y proporcione el código de error <strong>%{support_code}</strong>.
user_mailer.idv_please_call.body.intro_html: Llame a nuestro centro de contacto antes del <strong>%{date}</strong> para seguir verificando su identidad.
user_mailer.idv_please_call.header: Llámenos
user_mailer.idv_please_call.subject: Llame a %{app_name} para continuar con la verificación de identidad
user_mailer.in_person_completion_survey.body.cta.callout: Haga clic en el botón siguiente para empezar.
user_mailer.in_person_completion_survey.body.cta.label: Responda a nuestra encuesta
user_mailer.in_person_completion_survey.body.greeting: 'Hola:'
Expand All @@ -1904,10 +1908,6 @@ user_mailer.in_person_failed.intro: No se pudo verificar su identidad en la ofic
user_mailer.in_person_failed.subject: No se pudo verificar su identidad en persona
user_mailer.in_person_failed.verifying_identity: 'Cuando verifique su identidad:'
user_mailer.in_person_failed.verifying_step_not_expired: Su licencia de conducir o identificación emitida por el estado debe estar vigente. Actualmente no aceptamos otras formas de identificación, como pasaportes o identificaciones militares.
user_mailer.in_person_please_call.body.contact_message_html: Llame al <strong>%{contact_number}</strong> y proporcione el código de error <strong>%{support_code}</strong>.
user_mailer.in_person_please_call.body.intro_html: Llame a nuestro centro de contacto antes del <strong>%{date}</strong> para seguir verificando su identidad.
user_mailer.in_person_please_call.header: Llámenos
user_mailer.in_person_please_call.subject: Llame a %{app_name} para continuar con la verificación de identidad
user_mailer.in_person_ready_to_verify_reminder.greeting: 'Hola:'
user_mailer.in_person_ready_to_verify_reminder.heading.one: Le queda %{count} día para verificar su identidad en persona
user_mailer.in_person_ready_to_verify_reminder.heading.other: Le quedan %{count} días para verificar su identidad en persona
Expand Down
8 changes: 4 additions & 4 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1867,6 +1867,10 @@ user_mailer.email_deleted.header: Une adresse e-mail a été supprimée de votre
user_mailer.email_deleted.help_html: Si vous ne souhaitez pas supprimer cette adresse e-mail, veuillez visiter le %{help_link_html} de %{app_name_html} ou %{contact_link_html}.
user_mailer.email_deleted.subject: Adresse e-mail supprimée
user_mailer.help_link_text: Centre d’aide
user_mailer.idv_please_call.body.contact_message_html: Appelez le <strong>%{contact_number}</strong> et indiquez le code d’erreur <strong>%{support_code}</strong>.
user_mailer.idv_please_call.body.intro_html: Appelez notre centre de contact avant le <strong>%{date}</strong> pour continuer à vérifier votre identité.
user_mailer.idv_please_call.header: S’il vous plaît, appelez-nous
user_mailer.idv_please_call.subject: Appeler %{app_name} afin de poursuivre la vérification de votre identité
user_mailer.in_person_completion_survey.body.cta.callout: Cliquez sur le bouton ci-dessous pour commencer.
user_mailer.in_person_completion_survey.body.cta.label: Répondez à notre enquête
user_mailer.in_person_completion_survey.body.greeting: Bonjour,
Expand All @@ -1892,10 +1896,6 @@ user_mailer.in_person_failed.intro: Votre identité n’a pas pu être vérifié
user_mailer.in_person_failed.subject: Votre identité n’a pas pu être vérifiée en personne
user_mailer.in_person_failed.verifying_identity: 'Lors de la vérification de votre identité :'
user_mailer.in_person_failed.verifying_step_not_expired: Votre carte d’identité délivrée par l’État ou votre permis de conduire ne doit pas être périmé. Nous n’acceptons actuellement aucune autre pièce d’identité, comme les passeports et les cartes d’identité militaires.
user_mailer.in_person_please_call.body.contact_message_html: Appelez le <strong>%{contact_number}</strong> et indiquez le code d’erreur <strong>%{support_code}</strong>.
user_mailer.in_person_please_call.body.intro_html: Appelez notre centre de contact avant le <strong>%{date}</strong> pour continuer à vérifier votre identité.
user_mailer.in_person_please_call.header: S’il vous plaît, appelez-nous
user_mailer.in_person_please_call.subject: Appeler %{app_name} afin de poursuivre la vérification de votre identité
user_mailer.in_person_ready_to_verify_reminder.greeting: Bonjour,
user_mailer.in_person_ready_to_verify_reminder.heading.one: Il vous reste %{count} jour pour vérifier votre identité en personne
user_mailer.in_person_ready_to_verify_reminder.heading.other: Il vous reste %{count} jours pour vérifier votre identité en personne
Expand Down
8 changes: 4 additions & 4 deletions config/locales/zh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1880,6 +1880,10 @@ user_mailer.email_deleted.header: 一个电邮地址被从你的 %{app_name} 用
user_mailer.email_deleted.help_html: 如果你没有想删除这一电邮地址,请访问 %{app_name_html} %{help_link_html} 或者 %{contact_link_html}。
user_mailer.email_deleted.subject: 电邮地址已删除
user_mailer.help_link_text: 帮助中心
user_mailer.idv_please_call.body.contact_message_html: 打电话给 <strong>%{contact_number}</strong> 并向他们提供错误 代码 <strong>%{support_code}</strong>。
user_mailer.idv_please_call.body.intro_html: 请在 <strong>%{date}</strong> 之前给我们的联系中心打电话,以继续验证你的身份。
user_mailer.idv_please_call.header: 请给我们打个电话
user_mailer.idv_please_call.subject: 致电 %{app_name} 继续进行身份验证
user_mailer.in_person_completion_survey.body.cta.callout: 点击下面的按钮来开始
user_mailer.in_person_completion_survey.body.cta.label: 填写我们的意见调查
user_mailer.in_person_completion_survey.body.greeting: 你好,
Expand All @@ -1905,10 +1909,6 @@ user_mailer.in_person_failed.intro: 你的身份于 %{date}在 %{location} 邮
user_mailer.in_person_failed.subject: 你的身份未能亲身被验证。
user_mailer.in_person_failed.verifying_identity: '验证你的身份时:'
user_mailer.in_person_failed.verifying_step_not_expired: 你的州政府颁发的身份证件或驾照绝对没有过期。我们目前不接受任何其他形式的身份证件,比如护照和军队身份证件。
user_mailer.in_person_please_call.body.contact_message_html: 打电话给 <strong>%{contact_number}</strong> 并向他们提供错误 代码 <strong>%{support_code}</strong>。
user_mailer.in_person_please_call.body.intro_html: 请在 <strong>%{date}</strong> 之前给我们的联系中心打电话,以继续验证你的身份。
user_mailer.in_person_please_call.header: 请给我们打个电话
user_mailer.in_person_please_call.subject: 致电 %{app_name} 继续进行身份验证
user_mailer.in_person_ready_to_verify_reminder.greeting: 你好,
user_mailer.in_person_ready_to_verify_reminder.heading.one: 你距离亲身验证身份截止日期还有 %{count} 天
user_mailer.in_person_ready_to_verify_reminder.heading.other: 你距离亲身验证身份截止日期还有 %{count} 天
Expand Down
42 changes: 42 additions & 0 deletions spec/controllers/idv/enter_password_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
subject.idv_session
end

let(:threatmetrix_review_status) { 'pass' }

before do
stub_analytics
stub_sign_in(user)
Expand All @@ -27,6 +29,7 @@
subject.idv_session.flow_path = 'standard'
subject.idv_session.pii_from_doc = Pii::StateId.new(**Idp::Constants::MOCK_IDV_APPLICANT)
subject.idv_session.ssn = Idp::Constants::MOCK_IDV_APPLICANT_WITH_PHONE[:ssn]
subject.idv_session.threatmetrix_review_status = threatmetrix_review_status
subject.idv_session.threatmetrix_session_id = 'random-session-id'
subject.idv_session.resolution_successful = true
subject.idv_session.applicant = Idp::Constants::MOCK_IDV_APPLICANT_WITH_PHONE
Expand Down Expand Up @@ -404,6 +407,19 @@ def show
expect(events_count).to eq 1
end

context 'user was flagged for fraud' do
let(:threatmetrix_review_status) { 'reject' }

it 'sends the user a "please call us" email' do
put :create, params: { user: { password: ControllerHelper::VALID_PASSWORD } }
expect_delivered_email_count(1)
expect_delivered_email(
to: [user.email_addresses.first.email],
subject: t('user_mailer.idv_please_call.subject', app_name: APP_NAME),
)
end
end

context 'with in person profile' do
let!(:enrollment) do
create(:in_person_enrollment, :establishing, user: user, profile: nil)
Expand Down Expand Up @@ -450,6 +466,19 @@ def show
put :create, params: { user: { password: ControllerHelper::VALID_PASSWORD } }
end

context 'user was flagged for fraud' do
let(:threatmetrix_review_status) { 'reject' }

it 'does not send the user a "please call us" email' do
# For IPP, this is sent later, after the user goes to the post office.
put :create, params: { user: { password: ControllerHelper::VALID_PASSWORD } }
expect_email_not_delivered(
to: [user.email_addresses.first.email],
subject: t('user_mailer.idv_please_call.subject', app_name: APP_NAME),
)
end
end

it 'creates an in-person enrollment record' do
put :create, params: { user: { password: ControllerHelper::VALID_PASSWORD } }

Expand Down Expand Up @@ -896,6 +925,19 @@ def show
expect(profile).to_not be_active
end

context 'user was flagged for fraud' do
let(:threatmetrix_review_status) { 'reject' }

it 'does not send the user a "please call us" email' do
# For GPO, this is sent after they enter their code
put :create, params: { user: { password: ControllerHelper::VALID_PASSWORD } }
expect_email_not_delivered(
to: [user.email_addresses.first.email],
subject: t('user_mailer.idv_please_call.subject', app_name: APP_NAME),
)
end
end

it 'sends an email about the gpo letter' do
expect do
put :create,
Expand Down
7 changes: 2 additions & 5 deletions spec/jobs/get_usps_proofing_results_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1490,7 +1490,7 @@
allow(analytics).to receive(
:idv_in_person_usps_proofing_results_job_please_call_email_initiated,
)
allow(user_mailer).to receive(:in_person_please_call).and_return(mail_deliverer)
allow(user_mailer).to receive(:idv_please_call).and_return(mail_deliverer)
subject.perform(current_time)
end

Expand Down Expand Up @@ -1545,10 +1545,7 @@
end

it 'sends the please call email' do
expect(user_mailer).to have_received(:in_person_please_call).with(
enrollment: enrollment,
visited_location_name: visited_location_name,
)
expect(user_mailer).to have_received(:idv_please_call)
expect(mail_deliverer).to have_received(:deliver_later).with(
queue: :intentionally_delayed,
wait_until: (enrollment.reload.status_check_completed_at +
Expand Down
7 changes: 2 additions & 5 deletions spec/mailers/previews/user_mailer_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,8 @@ def in_person_failed_fraud
)
end

def in_person_please_call
UserMailer.with(user: user, email_address: email_address_record).in_person_please_call(
enrollment: in_person_enrollment_id_ipp,
visited_location_name: in_person_visited_location_name,
)
def idv_please_call
UserMailer.with(user: user, email_address: email_address_record).idv_please_call
end

def account_rejected
Expand Down
Loading