Skip to content
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

LG-14642: Update design and copy of GPO 'letter on the way' email #11351

Merged
merged 10 commits into from
Oct 28, 2024
Binary file added app/assets/images/email/letter-success.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 11 additions & 1 deletion app/helpers/locale_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@ def with_user_locale(user, &block)
locale = user.email_language

if I18n.locale_available?(locale)
I18n.with_locale(locale, &block)
if defined?(url_options)
I18n.with_locale(locale) do
url_options_locale = url_options[:locale]
url_options[:locale] = locale
block.call
ensure
url_options[:locale] = url_options_locale
end
else
I18n.with_locale(locale, &block)
end
else
Rails.logger.warn("user_id=#{user.uuid} has bad email_language=#{locale}") if locale.present?

Expand Down
12 changes: 10 additions & 2 deletions app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,15 @@ def please_reset_password

def verify_by_mail_letter_requested
with_user_locale(user) do
mail(to: email_address.email, subject: t('user_mailer.letter_reminder.subject'))
@hide_title = true
@presenter = Idv::ByMail::LetterRequestedEmailPresenter.new(
current_user: user,
url_options:,
)
mail(
to: email_address.email,
subject: t('user_mailer.verify_by_mail_letter_requested.subject'),
)
end
end

Expand Down Expand Up @@ -246,7 +254,7 @@ def account_verified(profile:)
attachments.inline['verified.png'] =
Rails.root.join('app/assets/images/email/user-signup-ial2.png').read
with_user_locale(user) do
@presenter = Idv::AccountVerifiedEmailPresenter.new(profile:)
@presenter = Idv::AccountVerifiedEmailPresenter.new(profile:, url_options:)
@hide_title = true
@date = I18n.l(profile.verified_at, format: :event_date)
mail(
Expand Down
9 changes: 3 additions & 6 deletions app/presenters/idv/account_verified_email_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ module Idv
class AccountVerifiedEmailPresenter
include Rails.application.routes.url_helpers

attr_reader :profile
attr_reader :profile, :url_options

def initialize(profile:)
def initialize(profile:, url_options:)
@profile = profile
@url_options = url_options
end

def service_provider
Expand All @@ -30,10 +31,6 @@ def sp_name
service_provider&.friendly_name || APP_NAME
end

def url_options
{}
end

private

def sp_return_url_resolver
Expand Down
47 changes: 47 additions & 0 deletions app/presenters/idv/by_mail/letter_requested_email_presenter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# frozen_string_literal: true

module Idv
module ByMail
class LetterRequestedEmailPresenter
include ActionView::Helpers::TranslationHelper
include Rails.application.routes.url_helpers

attr_reader :current_user, :service_provider, :url_options
def initialize(current_user:, url_options:)
@current_user = current_user
@url_options = url_options
@service_provider = current_user.pending_profile&.initiating_service_provider
end

def sp_name
service_provider&.friendly_name
end

def show_sp_contact_instructions?
sp_name.present?
end

def show_cta?
lmgeorge marked this conversation as resolved.
Show resolved Hide resolved
sign_in_url.present?
end

def sign_in_url
if service_provider.present?
service_provider_homepage_url
else
root_url
end
end
lmgeorge marked this conversation as resolved.
Show resolved Hide resolved

private

def service_provider_homepage_url
sp_return_url_resolver.homepage_url if service_provider
end

def sp_return_url_resolver
SpReturnUrlResolver.new(service_provider:)
end
end
end
end
73 changes: 55 additions & 18 deletions app/views/user_mailer/verify_by_mail_letter_requested.html.erb
Original file line number Diff line number Diff line change
@@ -1,21 +1,58 @@
<p class="lead">
<%= t('user_mailer.letter_reminder.info_html', link_html: link_to(APP_NAME, root_url)) %>
<%= image_tag(
'email/letter-success.png',
width: 140,
height: 177,
alt: '',
class: 'float-center padding-bottom-4',
) %>
<h1><%= message.subject %></h1>
<p>
<%= t('user_mailer.verify_by_mail_letter_requested.intro_html', app_name: APP_NAME) %>
</p>
<!-- When there is a service provider present render this block -->
<% if @presenter.show_sp_contact_instructions? %>
<ul>
<li><%= t('user_mailer.verify_by_mail_letter_requested.instructions.sign_in') %></li>
<li>
<%= t(
'user_mailer.verify_by_mail_letter_requested.instructions.contact_sp',
friendly_name: @presenter.sp_name,
) %>
</li>
</ul>
<% else %>
<p><%= t('user_mailer.verify_by_mail_letter_requested.instructions.sign_in') %></p>
<% end %>

<table class="spacer">
<tbody>
<tr>
<td class="s10" height="10px">
&nbsp;
</td>
</tr>
</tbody>
</table>

<table class="hr">
<tr>
<th>
&nbsp;
</th>
</tr>
</table>
<% if @presenter.show_cta? %>
<div class="margin-top-5">
<table class="button expanded large radius">
<tbody>
<tr>
<td>
<table>
<tbody>
<tr>
<td style="text-align: center">
<%= link_to t('user_mailer.verify_by_mail_letter_requested.cta.sign_in'),
@presenter.sign_in_url,
target: '_blank',
class: 'float-center',
rel: 'noopener' %>
</td>
</tr>
</tbody>
</table>
</td>
<td class="expander"></td>
</tr>
</tbody>
</table>
</div>

<p>
<%= link_to @presenter.sign_in_url, @presenter.sign_in_url, target: '_blank', rel: 'noopener' %>
</p>
<% end %>

7 changes: 5 additions & 2 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1890,8 +1890,6 @@ user_mailer.letter_reminder_14_days.did_not_get_a_letter_html: If you didn’t g
user_mailer.letter_reminder_14_days.finish: Finish verifying your identity
user_mailer.letter_reminder_14_days.sign_in_and_request_another_letter: sign in to request another letter
user_mailer.letter_reminder_14_days.subject: Finish verifying your identity
user_mailer.letter_reminder.info_html: The letter you are about to receive will contain a verification code that helps us verify your address. You can complete the identity verification process by signing into %{link_html} and entering the verification code.
user_mailer.letter_reminder.subject: We mailed a letter to the address you have on file
user_mailer.new_device_sign_in_after_2fa.authentication_methods: authentication methods
user_mailer.new_device_sign_in_after_2fa.info_p1: Your %{app_name} email and password were used to sign-in and authenticate on a new device.
user_mailer.new_device_sign_in_after_2fa.info_p2: If you recognize this activity, you don’t need to do anything.
Expand Down Expand Up @@ -1947,6 +1945,11 @@ user_mailer.suspended_reset_password.subject: We couldn’t reset your password
user_mailer.suspension_confirmed.contact_agency: Please contact the agency whose service you are trying to access.
user_mailer.suspension_confirmed.remain_locked: We have completed our review of your %{app_name} account and your account will remain locked.
user_mailer.suspension_confirmed.subject: Your account is locked
user_mailer.verify_by_mail_letter_requested.cta.sign_in: Sign in
user_mailer.verify_by_mail_letter_requested.instructions.contact_sp: Contact %{friendly_name} if you need to access their services before your letter arrives.
user_mailer.verify_by_mail_letter_requested.instructions.sign_in: Sign back in and enter the verification code when your letter arrives.
user_mailer.verify_by_mail_letter_requested.intro_html: You’ll get a letter in the mail from %{app_name} in <strong>5 to 10</strong> days at the address we verified and associated with you.
user_mailer.verify_by_mail_letter_requested.subject: Your letter is on the way
users.delete.actions.cancel: Back to profile
users.delete.actions.delete: Delete account
users.delete.bullet_1: You won’t have a %{app_name} account
Expand Down
7 changes: 5 additions & 2 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1902,8 +1902,6 @@ user_mailer.letter_reminder_14_days.did_not_get_a_letter_html: Si no recibió es
user_mailer.letter_reminder_14_days.finish: Termine de verificar su identidad
user_mailer.letter_reminder_14_days.sign_in_and_request_another_letter: inicie sesión para solicitar otra carta
user_mailer.letter_reminder_14_days.subject: Termine de verificar su identidad
user_mailer.letter_reminder.info_html: La carta que recibirá próximamente contiene un código de verificación que nos ayudará a verificar su dirección. Para completar el proceso de verificación de identidad, inicie sesión en %{link_html} e ingrese el código de verificación.
user_mailer.letter_reminder.subject: Enviamos una carta a la dirección de su expediente
user_mailer.new_device_sign_in_after_2fa.authentication_methods: métodos de autenticación
user_mailer.new_device_sign_in_after_2fa.info_p1: Su correo electrónico y contraseña de %{app_name} se usaron para iniciar sesión y hacer la autenticación en un dispositivo nuevo.
user_mailer.new_device_sign_in_after_2fa.info_p2: Si reconoce esta actividad, no tiene que hacer nada.
Expand Down Expand Up @@ -1959,6 +1957,11 @@ user_mailer.suspended_reset_password.subject: No pudimos restablecer su contrase
user_mailer.suspension_confirmed.contact_agency: Contacte con la agencia a cuyo servicio está intentando acceder.
user_mailer.suspension_confirmed.remain_locked: Terminamos la revisión de su cuenta de %{app_name} y la cuenta permanecerá bloqueada.
user_mailer.suspension_confirmed.subject: Su cuenta está bloqueada
user_mailer.verify_by_mail_letter_requested.cta.sign_in: Iniciar sesión
user_mailer.verify_by_mail_letter_requested.instructions.contact_sp: Contacte con %{friendly_name} si necesita acceder a los servicios de esa agencia antes de que llegue su carta.
user_mailer.verify_by_mail_letter_requested.instructions.sign_in: Cuando reciba su carta, vuelva a iniciar sesión e ingrese el código de verificación.
user_mailer.verify_by_mail_letter_requested.intro_html: 'En un plazo de <strong>5 a 10</strong> días, recibirá por correo una carta de %{app_name} en la dirección que verificamos y asociamos con usted:'
user_mailer.verify_by_mail_letter_requested.subject: Su carta está en camino
users.delete.actions.cancel: Volver al perfil
users.delete.actions.delete: Eliminar cuenta
users.delete.bullet_1: No tendrá una cuenta de %{app_name}.
Expand Down
7 changes: 5 additions & 2 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1890,8 +1890,6 @@ user_mailer.letter_reminder_14_days.did_not_get_a_letter_html: Si vous n’avez
user_mailer.letter_reminder_14_days.finish: Terminer la vérification de votre identité
user_mailer.letter_reminder_14_days.sign_in_and_request_another_letter: connectez-vous pour en demander une autre
user_mailer.letter_reminder_14_days.subject: Terminer la vérification de votre identité
user_mailer.letter_reminder.info_html: La lettre que vous êtes sur le point de recevoir contiendra un code de vérification nous permettant de vérifier votre adresse. Vous pouvez terminer le processus de vérification d’identité en vous connectant à %{link_html} et en saisissant le code de vérification.
user_mailer.letter_reminder.subject: Nous avons posté une lettre à l’adresse que vous avez enregistrée
user_mailer.new_device_sign_in_after_2fa.authentication_methods: méthodes d’authentification
user_mailer.new_device_sign_in_after_2fa.info_p1: Votre e-mail et mot de passe %{app_name} ont été utilisés pour se connecter et s’authentifier sur un nouvel appareil.
user_mailer.new_device_sign_in_after_2fa.info_p2: Si vous reconnaissez cette activité, vous n’avez rien à faire.
Expand Down Expand Up @@ -1947,6 +1945,11 @@ user_mailer.suspended_reset_password.subject: Nous n’avons pas pu réinitialis
user_mailer.suspension_confirmed.contact_agency: Veuillez contacter l’organisme dont vous essayez d’accéder au service.
user_mailer.suspension_confirmed.remain_locked: Nous avons terminé l’examen de votre compte %{app_name} et votre compte restera verrouillé.
user_mailer.suspension_confirmed.subject: Votre compte est verrouillé
user_mailer.verify_by_mail_letter_requested.cta.sign_in: Connexion
user_mailer.verify_by_mail_letter_requested.instructions.contact_sp: Contactez %{friendly_name} si vous avez besoin d’accéder à ses services avant l’arrivée de votre lettre.
user_mailer.verify_by_mail_letter_requested.instructions.sign_in: Une fois ce courrier reçu, reconnectez-vous pour saisir le code de vérification qui y figure.
user_mailer.verify_by_mail_letter_requested.intro_html: 'Vous recevrez un courrier de %{app_name} d’ici <strong>5 à 10</strong> jours à l’adresse que nous avons confirmée qui est associée à votre nom :'
user_mailer.verify_by_mail_letter_requested.subject: Votre lettre est en route
users.delete.actions.cancel: Retour au profil
users.delete.actions.delete: Supprimer le compte
users.delete.bullet_1: Vous n’aurez pas de compte %{app_name}.
Expand Down
7 changes: 5 additions & 2 deletions config/locales/zh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1903,8 +1903,6 @@ user_mailer.letter_reminder_14_days.did_not_get_a_letter_html: 如果你没有
user_mailer.letter_reminder_14_days.finish: 完成验证你的身份
user_mailer.letter_reminder_14_days.sign_in_and_request_another_letter: 登录要求再发一封信
user_mailer.letter_reminder_14_days.subject: 完成验证你的身份
user_mailer.letter_reminder.info_html: 你将收到的信件会含有帮助我们验证你地址的一次性代码。你可以登入 %{link_html} 并输入该一次性代码来完成身份验证流i程。
user_mailer.letter_reminder.subject: 我们已向你存档地址发送了一封信。
user_mailer.new_device_sign_in_after_2fa.authentication_methods: 身份证实方法
user_mailer.new_device_sign_in_after_2fa.info_p1: 你的 %{app_name} 电邮和密码在一个新设备上被用来登录和进行身份验证。
user_mailer.new_device_sign_in_after_2fa.info_p2: 如果你知道该活动,则无需做任何事情。
Expand Down Expand Up @@ -1960,6 +1958,11 @@ user_mailer.suspended_reset_password.subject: 我们无法重设你的密码。
user_mailer.suspension_confirmed.contact_agency: 请联系你试图访问其服务的那个机构。
user_mailer.suspension_confirmed.remain_locked: 我们已完成了对你%{app_name}账户的审查,你的账户将继续被锁。
user_mailer.suspension_confirmed.subject: 你的账户被锁
user_mailer.verify_by_mail_letter_requested.cta.sign_in: 登录
user_mailer.verify_by_mail_letter_requested.instructions.contact_sp: 如果收到信件之前你需要访问我们合作伙伴机构的服务,请联系%{friendly_name}。
user_mailer.verify_by_mail_letter_requested.instructions.sign_in: 收到信件后请再登录并输入其中的验证码。
user_mailer.verify_by_mail_letter_requested.intro_html: '你会在<strong>5到10</strong>天内在我们验证过的与你相关的地址收到来自%{app_name}寄给你的一封信:'
user_mailer.verify_by_mail_letter_requested.subject: 你的信件已寄出。
users.delete.actions.cancel: 返回用户资料
users.delete.actions.delete: 删除账户
users.delete.bullet_1: 你不会有 %{app_name} 账户
Expand Down
1 change: 1 addition & 0 deletions spec/controllers/idv/verify_info_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@
before do
controller.idv_session.ssn = nil
end

it 'does not log an idv_verify_info_missing_threatmetrix_session_id event' do
get :show
expect(@analytics).not_to have_logged_event(
Expand Down
2 changes: 1 addition & 1 deletion spec/features/idv/steps/enter_password_step_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def sends_letter_creates_unverified_profile_sends_email
to change { GpoConfirmation.count }.by(1)

expect_delivered_email_count(email_count_before_continue + 1)
expect(last_email.subject).to eq(t('user_mailer.letter_reminder.subject'))
expect(last_email.subject).to eq(t('user_mailer.verify_by_mail_letter_requested.subject'))

expect(user.events.account_verified.size).to be(0)
expect(user.profiles.count).to eq 1
Expand Down
1 change: 1 addition & 0 deletions spec/helpers/locale_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@

context 'when the user has an email_language' do
let(:email_language) { 'es' }
let(:url_options) { {} }

it 'sets the language inside the block and yields' do
subject
Expand Down
2 changes: 1 addition & 1 deletion spec/i18n_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def allowed_untranslated_key?(locale, key)
)
end

it 'has matching HTML tags' do
it 'has matching HTML tags across all locales' do
lmgeorge marked this conversation as resolved.
Show resolved Hide resolved
i18n.data[i18n.base_locale].select_keys do |key, _node|
if key.start_with?('i18n.transliterate.rule.') || i18n.t(key).is_a?(Array) || i18n.t(key).nil?
next
Expand Down
9 changes: 9 additions & 0 deletions spec/mailers/previews/user_mailer_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ def please_reset_password
end

def verify_by_mail_letter_requested
service_provider = unsaveable(
ServiceProvider.new(
friendly_name: 'Sample App SP',
return_to_sp_url: 'https://example.com',
),
)
profile = Profile.new(initiating_service_provider: service_provider)
user.instance_variable_set(:@pending_profile, profile)
UserMailer.with(user: user, email_address: email_address_record).verify_by_mail_letter_requested
end

Expand Down Expand Up @@ -286,6 +294,7 @@ def user
),
),
],
email_language: params[:locale],
),
)
end
Expand Down
Loading