Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
eff5a1c
WIP: interpolate logingov
zachmargolis Oct 13, 2021
f322f6e
more
zachmargolis Oct 13, 2021
0bb5e61
moar
zachmargolis Oct 13, 2021
25d2999
moar
zachmargolis Oct 13, 2021
5f8efbd
rename stuffs
zachmargolis Oct 13, 2021
f77244d
spec message
zachmargolis Oct 13, 2021
003ce7e
wip
zachmargolis Oct 13, 2021
2b068ef
lints
zachmargolis Oct 13, 2021
1c1d7de
fix specs
zachmargolis Oct 14, 2021
0588fb5
Re-translate strings to be interpolated
zachmargolis Oct 14, 2021
9aeb619
some fixes
zachmargolis Oct 14, 2021
ffc25d3
more fixessss
zachmargolis Oct 14, 2021
3f38cdb
lints
zachmargolis Oct 14, 2021
5f37004
i think we did it
zachmargolis Oct 14, 2021
6dc4595
fix more tests
zachmargolis Oct 14, 2021
61feb13
update interpolation in specs
zachmargolis Oct 14, 2021
3a9d386
Change %{app} => %{app_name} for consistency
zachmargolis Oct 14, 2021
3491ff1
normalize yaml
zachmargolis Oct 14, 2021
a826a53
add missing subject interpolation
zachmargolis Oct 14, 2021
003f30c
lint
zachmargolis Oct 14, 2021
fdf066d
javascript
zachmargolis Oct 14, 2021
8bee669
nother spec
zachmargolis Oct 14, 2021
6e8b3b5
subject tests
zachmargolis Oct 14, 2021
aa2dee1
js fixes
zachmargolis Oct 14, 2021
1bbee5e
html safe interpolation
zachmargolis Oct 14, 2021
3fe7c7f
Merge branch 'main' into margolis-lg-4886-interpolate-logingov
zachmargolis Oct 14, 2021
f07862d
Remove some newlines that snuck in there
zachmargolis Oct 14, 2021
cbe59e4
Update spec to reference constant
zachmargolis Oct 14, 2021
cf38a02
Update app/views/account_reset/confirm_delete_account/show.html.erb
zachmargolis Oct 14, 2021
ffc15ad
add another interp
zachmargolis Oct 14, 2021
c601b7c
Remove unused interp argument
zachmargolis Oct 14, 2021
ed82f1e
Revert "Remove unused interp argument"
zachmargolis Oct 14, 2021
d9aa159
Make specs yell when %{} does not match args
zachmargolis Oct 14, 2021
1138ff0
fix extra/missing interp arguments
zachmargolis Oct 14, 2021
a583ff9
lints
zachmargolis Oct 14, 2021
f95ee2c
add a few more known args
zachmargolis Oct 14, 2021
a825382
remove "extra_keys" check, that was too sensitive
zachmargolis Oct 14, 2021
d23bc76
remove i18n.t overrides for specs, too picky
zachmargolis Oct 14, 2021
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
5 changes: 4 additions & 1 deletion app/controllers/account_reset/cancel_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ def handle_invalid_token(result)

def handle_success
sign_out if current_user
flash[:success] = t('two_factor_authentication.account_reset.successful_cancel')
flash[:success] = t(
'two_factor_authentication.account_reset.successful_cancel',
app_name: APP_NAME,
)
end

def token
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/idv/review_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def init_profile
UserAlerts::AlertUserAboutAccountVerified.call(
user: current_user,
date_time: event.created_at,
app: decorated_session.sp_name,
sp_name: decorated_session.sp_name,
disavowal_token: event.disavowal_token,
)
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users/email_confirmations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def message_for_already_confirmed_user
if email_address_already_confirmed_by_current_user?
t('devise.confirmations.already_confirmed', action: nil)
elsif user_signed_in?
t('devise.confirmations.confirmed_but_remove_from_other_account')
t('devise.confirmations.confirmed_but_remove_from_other_account', app_name: APP_NAME)
else
action_text = t('devise.confirmations.sign_in')
t('devise.confirmations.already_confirmed', action: action_text)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def timeout
sign_out
flash[:info] = t(
'notices.session_timedout',
app: APP_NAME,
app_name: APP_NAME,
minutes: IdentityConfig.store.session_timeout_in_minutes,
)
redirect_to root_url(request_id: request_id)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users/verify_account_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def create
UserAlerts::AlertUserAboutAccountVerified.call(
user: current_user,
date_time: event.created_at,
app: decorated_session.sp_name,
sp_name: decorated_session.sp_name,
disavowal_token: event.disavowal_token,
)
flash[:success] = t('account.index.verification.success')
Expand Down
4 changes: 3 additions & 1 deletion app/decorators/service_provider_session_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ def custom_alert(section)
return if sp.help_text.nil?
language = I18n.locale.to_s
alert = sp.help_text.dig(section, language)
format(alert, sp_name: sp_name, sp_create_link: sp_create_link) if alert.present?
if alert.present?
format(alert, sp_name: sp_name, sp_create_link: sp_create_link, app_name: APP_NAME)
end
end

def sp_logo
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 @@ -151,9 +151,9 @@ def connected_apps

def delete_account_bullet_key
if identity_verified?
I18n.t('users.delete.bullet_2_loa3', app: APP_NAME)
I18n.t('users.delete.bullet_2_loa3', app_name: APP_NAME)
else
I18n.t('users.delete.bullet_2_loa1', app: APP_NAME)
I18n.t('users.delete.bullet_2_loa1', app_name: APP_NAME)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
useState,
useEffect,
useCallback,
useContext,
useMemo,
useImperativeHandle,
} from 'react';
Expand All @@ -14,6 +15,7 @@ import useIfStillMounted from '../hooks/use-if-still-mounted';
import useInstanceId from '../hooks/use-instance-id';
import useFocusFallbackRef from '../hooks/use-focus-fallback-ref';
import './selfie-capture.scss';
import AppContext from '../context/app';

/** @typedef {import('react').ReactNode} ReactNode */

Expand Down Expand Up @@ -152,6 +154,8 @@ function SelfieCapture({ value, onChange, errorMessage, className }, ref) {

const labelId = `selfie-capture-label-${instanceId}`;

const { appName } = useContext(AppContext);

return (
<>
<div
Expand Down Expand Up @@ -229,13 +233,21 @@ function SelfieCapture({ value, onChange, errorMessage, className }, ref) {
<>
<div className="selfie-capture__consent-prompt">
<strong className="selfie-capture__consent-prompt-banner usa-file-input__banner-text">
{t('doc_auth.instructions.document_capture_selfie_consent_banner')}
{t('doc_auth.instructions.document_capture_selfie_consent_banner', {
app_name: appName,
})}
</strong>
{isAccessRejected ? (
<>
<p>{t('doc_auth.instructions.document_capture_selfie_consent_blocked')}</p>
<p>
{t('doc_auth.instructions.document_capture_selfie_consent_blocked_action')}
{t('doc_auth.instructions.document_capture_selfie_consent_blocked', {
app_name: appName,
})}
</p>
<p>
{t('doc_auth.instructions.document_capture_selfie_consent_blocked_action', {
app_name: appName,
})}
</p>
</>
) : (
Expand Down
13 changes: 13 additions & 0 deletions app/javascript/packages/document-capture/context/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { createContext } from 'react';

/**
* @typedef AppContext
*
* @prop {string} appName name of the application (probably Login.gov)
*/

const AppContext = createContext(/** @type {AppContext} */ ({ appName: '' }));

AppContext.displayName = 'AppContext';

export default AppContext;
1 change: 1 addition & 0 deletions app/javascript/packages/document-capture/context/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { default as AppContext } from './app';
export { default as AssetContext } from './asset';
export { default as DeviceContext } from './device';
export { default as AcuantContext, Provider as AcuantContextProvider } from './acuant';
Expand Down
69 changes: 38 additions & 31 deletions app/javascript/packs/document-capture.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { render } from 'react-dom';
import {
AppContext,
DocumentCapture,
AssetContext,
DeviceContext,
Expand Down Expand Up @@ -133,39 +134,45 @@ loadPolyfills(['fetch', 'crypto', 'url']).then(async () => {
const keepAlive = () =>
window.fetch(keepAliveEndpoint, { method: 'POST', headers: { 'X-CSRF-Token': csrf } });

const appContext = {
appName: /** @type string */ (appRoot.dataset.appName),
};

render(
<DeviceContext.Provider value={device}>
<AnalyticsContext.Provider value={{ addPageAction, noticeError }}>
<AcuantContextProvider
credentials={getMetaContent('acuant-sdk-initialization-creds')}
endpoint={getMetaContent('acuant-sdk-initialization-endpoint')}
glareThreshold={glareThreshold}
sharpnessThreshold={sharpnessThreshold}
>
<UploadContextProvider
endpoint={/** @type {string} */ (appRoot.getAttribute('data-endpoint'))}
statusEndpoint={/** @type {string} */ (appRoot.getAttribute('data-status-endpoint'))}
statusPollInterval={
Number(appRoot.getAttribute('data-status-poll-interval-ms')) || undefined
}
method={isAsyncForm ? 'PUT' : 'POST'}
csrf={csrf}
isMockClient={isMockClient}
backgroundUploadURLs={backgroundUploadURLs}
backgroundUploadEncryptKey={backgroundUploadEncryptKey}
formData={formData}
<AppContext.Provider value={appContext}>
<DeviceContext.Provider value={device}>
<AnalyticsContext.Provider value={{ addPageAction, noticeError }}>
<AcuantContextProvider
credentials={getMetaContent('acuant-sdk-initialization-creds')}
endpoint={getMetaContent('acuant-sdk-initialization-endpoint')}
glareThreshold={glareThreshold}
sharpnessThreshold={sharpnessThreshold}
>
<I18nContext.Provider value={i18n.strings}>
<ServiceProviderContextProvider value={getServiceProvider()}>
<AssetContext.Provider value={assets}>
<DocumentCapture isAsyncForm={isAsyncForm} onStepChange={keepAlive} />
</AssetContext.Provider>
</ServiceProviderContextProvider>
</I18nContext.Provider>
</UploadContextProvider>
</AcuantContextProvider>
</AnalyticsContext.Provider>
</DeviceContext.Provider>,
<UploadContextProvider
endpoint={/** @type {string} */ (appRoot.getAttribute('data-endpoint'))}
statusEndpoint={/** @type {string} */ (appRoot.getAttribute('data-status-endpoint'))}
statusPollInterval={
Number(appRoot.getAttribute('data-status-poll-interval-ms')) || undefined
}
method={isAsyncForm ? 'PUT' : 'POST'}
csrf={csrf}
isMockClient={isMockClient}
backgroundUploadURLs={backgroundUploadURLs}
backgroundUploadEncryptKey={backgroundUploadEncryptKey}
formData={formData}
>
<I18nContext.Provider value={i18n.strings}>
<ServiceProviderContextProvider value={getServiceProvider()}>
<AssetContext.Provider value={assets}>
<DocumentCapture isAsyncForm={isAsyncForm} onStepChange={keepAlive} />
</AssetContext.Provider>
</ServiceProviderContextProvider>
</I18nContext.Provider>
</UploadContextProvider>
</AcuantContextProvider>
</AnalyticsContext.Provider>
</DeviceContext.Provider>
</AppContext.Provider>,
appRoot,
);
});
32 changes: 23 additions & 9 deletions app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def phone_added(user, email_address, disavowal_token:)

def account_does_not_exist(email, request_id)
@sign_up_email_url = sign_up_email_url(request_id: request_id, locale: locale_url_param)
mail(to: email, subject: t('user_mailer.account_does_not_exist.subject'))
mail(to: email, subject: t('user_mailer.account_does_not_exist.subject', app_name: APP_NAME))
end

def personal_key_sign_in(user, email, disavowal_token:)
Expand All @@ -91,7 +91,10 @@ def new_device_sign_in(user:, email_address:, date:, location:, disavowal_token:
@login_date = date
@login_location = location
@disavowal_token = disavowal_token
mail(to: email_address.email, subject: t('user_mailer.new_device_sign_in.subject'))
mail(
to: email_address.email,
subject: t('user_mailer.new_device_sign_in.subject', app_name: APP_NAME),
)
end
end

Expand All @@ -107,15 +110,21 @@ def account_reset_request(user, email_address, account_reset)
with_user_locale(user) do
@token = account_reset&.request_token
@header = t('user_mailer.account_reset_request.header')
mail(to: email_address.email, subject: t('user_mailer.account_reset_request.subject'))
mail(
to: email_address.email,
subject: t('user_mailer.account_reset_request.subject', app_name: APP_NAME),
)
end
end

def account_reset_granted(user, email_address, account_reset)
with_user_locale(user) do
@token = account_reset&.request_token
@granted_token = account_reset&.granted_token
mail(to: email_address.email, subject: t('user_mailer.account_reset_granted.subject'))
mail(
to: email_address.email,
subject: t('user_mailer.account_reset_granted.subject', app_name: APP_NAME),
)
end
end

Expand All @@ -133,7 +142,10 @@ def account_reset_cancel(user, email_address)

def please_reset_password(user, email_address)
with_user_locale(user) do
mail(to: email_address, subject: t('user_mailer.please_reset_password.subject'))
mail(
to: email_address,
subject: t('user_mailer.please_reset_password.subject', app_name: APP_NAME),
)
end
end

Expand Down Expand Up @@ -197,15 +209,17 @@ def deleted_user_accounts_report(email:, name:, issuers:, data:)
mail(to: email, subject: t('user_mailer.deleted_accounts_report.subject'))
end

def account_verified(user, email_address, date_time:, app:, disavowal_token:)
def account_verified(user, email_address, date_time:, sp_name:, disavowal_token:)
return unless email_should_receive_nonessential_notifications?(email_address.email)

with_user_locale(user) do
@date = I18n.localize(date_time, format: t('time.formats.event_date'))
@app = app
@sp_name = sp_name
@disavowal_token = disavowal_token
@app_name = APP_NAME
mail(to: email_address.email, subject: t('user_mailer.account_verified.subject', app: @app))
mail(
to: email_address.email,
subject: t('user_mailer.account_verified.subject', sp_name: @sp_name),
)
end
end

Expand Down
6 changes: 3 additions & 3 deletions app/presenters/cancellation_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ def header

def cancellation_warnings
[
t('users.delete.bullet_1', app: APP_NAME),
t('users.delete.bullet_1', app_name: APP_NAME),
t('users.delete.bullet_2_loa1'),
t('users.delete.bullet_3', app: APP_NAME),
t('users.delete.bullet_4', app: APP_NAME),
t('users.delete.bullet_3', app_name: APP_NAME),
t('users.delete.bullet_4', app_name: APP_NAME),
]
end

Expand Down
4 changes: 2 additions & 2 deletions app/presenters/confirmation_email_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ def first_sentence
if user.confirmed_at?
I18n.t(
'user_mailer.email_confirmation_instructions.first_sentence.confirmed',
app: app_link, confirmation_period: confirmation_period,
app_name: app_link, confirmation_period: confirmation_period,
)
else
I18n.t(
'user_mailer.email_confirmation_instructions.first_sentence.unconfirmed',
app: app_link, confirmation_period: confirmation_period,
app_name: app_link, confirmation_period: confirmation_period,
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/piv_cac_authentication_login_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def heading
end

def info
t('instructions.mfa.piv_cac.sign_in')
t('instructions.mfa.piv_cac.sign_in', app_name: APP_NAME)
end

def url_options
Expand Down
1 change: 1 addition & 0 deletions app/presenters/piv_cac_error_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def description
when 'user.not_found'
t(
'instructions.mfa.piv_cac.account_not_found_html',
app_name: APP_NAME,
sign_in: @view.link_to(t('headings.sign_in_without_sp'), root_url),
create_account: @view.link_to(t('links.create_account'), sign_up_email_url),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def help_text
t(
"instructions.mfa.#{two_factor_authentication_method}.confirm_code_html",
email: content_tag(:strong, user_email),
app: content_tag(:strong, APP_NAME),
app_name: content_tag(:strong, APP_NAME),
)
end

Expand Down
5 changes: 4 additions & 1 deletion app/services/request_password_reset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ def send_reset_password_instructions
end

def instructions
I18n.t('user_mailer.email_confirmation_instructions.first_sentence.forgot_password')
I18n.t(
'user_mailer.email_confirmation_instructions.first_sentence.forgot_password',
app_name: APP_NAME,
)
end

##
Expand Down
6 changes: 3 additions & 3 deletions app/services/user_alerts/alert_user_about_account_verified.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module UserAlerts
class AlertUserAboutAccountVerified
def self.call(user:, date_time:, app:, disavowal_token:)
app ||= APP_NAME
def self.call(user:, date_time:, sp_name:, disavowal_token:)
sp_name ||= APP_NAME
user.confirmed_email_addresses.each do |email_address|
UserMailer.account_verified(
user,
email_address,
date_time: date_time,
app: app,
sp_name: sp_name,
disavowal_token: disavowal_token,
).deliver_now
end
Expand Down
Loading