Skip to content

Commit b21ecb1

Browse files
authored
Merge pull request #18217 from mozilla/FXA-10921
feat(emails): Add new emails for sign-in with recovery methods
2 parents 5eac7e1 + 6338c12 commit b21ecb1

26 files changed

Lines changed: 334 additions & 15 deletions

File tree

packages/fxa-auth-server/lib/metrics/amplitude.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ const EMAIL_TYPES = {
6868
postAddRecoveryPhone: '2fa',
6969
postRemoveRecoveryPhone: '2fa',
7070
postChangeRecoveryPhone: '2fa',
71+
postSigninRecoveryPhone: 'login',
72+
postSigninRecoveryCode: 'login',
7173
recovery: 'reset_password',
7274
unblockCode: 'unblock',
7375
verify: 'registration',

packages/fxa-auth-server/lib/senders/email.js

Lines changed: 67 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ module.exports = function (log, config, bounces) {
8787
postAddRecoveryPhone: 'recovery-phone-added',
8888
postChangeRecoveryPhone: 'recovery-phone-changed',
8989
postRemoveRecoveryPhone: 'recovery-phone-removed',
90+
postSigninRecoveryPhone: 'signin-recovery-phone',
91+
postSigninRecoveryCode: 'signin-recovery-code',
9092
recovery: 'forgot-password',
9193
unblockCode: 'new-unblock',
9294
verify: 'welcome',
@@ -140,6 +142,8 @@ module.exports = function (log, config, bounces) {
140142
postChangeAccountRecovery: 'manage-account',
141143
postRemoveAccountRecovery: 'manage-account',
142144
postAddRecoveryPhone: 'manage-account',
145+
postSigninRecoveryPhone: 'manage-account',
146+
postSigninRecoveryCode: 'manage-account',
143147
recovery: 'reset-password',
144148
unblockCode: 'unblock-code',
145149
verify: 'activate',
@@ -1584,19 +1588,14 @@ module.exports = function (log, config, bounces) {
15841588

15851589
Mailer.prototype.postAddRecoveryPhoneEmail = function (message) {
15861590
const templateName = 'postAddRecoveryPhone';
1587-
const links = this._generateLinks(
1588-
this.initiatePasswordResetUrl,
1589-
message,
1590-
{},
1591-
templateName
1592-
);
1591+
const links = this._generateSettingLinks(message, templateName);
15931592
const [time, date] = this._constructLocalTimeString(
15941593
message.timeZone,
15951594
message.acceptLanguage
15961595
);
15971596

15981597
const headers = {
1599-
'X-Link': links.resetLink,
1598+
'X-Link': links.link,
16001599
};
16011600

16021601
return this.send({
@@ -1676,7 +1675,7 @@ module.exports = function (log, config, bounces) {
16761675
);
16771676

16781677
const headers = {
1679-
'X-Link': links.resetLink,
1678+
'X-Link': links.link,
16801679
};
16811680

16821681
return this.send({
@@ -1696,6 +1695,66 @@ module.exports = function (log, config, bounces) {
16961695
});
16971696
};
16981697

1698+
Mailer.prototype.postSigninRecoveryPhoneEmail = function (message) {
1699+
const templateName = 'postSigninRecoveryPhone';
1700+
const links = this._generateSettingLinks(message, templateName);
1701+
const [time, date] = this._constructLocalTimeString(
1702+
message.timeZone,
1703+
message.acceptLanguage
1704+
);
1705+
1706+
const headers = {
1707+
'X-Link': links.link,
1708+
};
1709+
1710+
return this.send({
1711+
...message,
1712+
headers,
1713+
template: templateName,
1714+
templateValues: {
1715+
date,
1716+
device: this._formatUserAgentInfo(message),
1717+
privacyUrl: links.privacyUrl,
1718+
link: links.link,
1719+
resetLink: links.resetLink,
1720+
resetLinkAttributes: links.resetLinkAttributes,
1721+
supportLinkAttributes: links.supportLinkAttributes,
1722+
supportUrl: links.supportUrl,
1723+
time,
1724+
},
1725+
});
1726+
};
1727+
1728+
Mailer.prototype.postSigninRecoveryCodeEmail = function (message) {
1729+
const templateName = 'postSigninRecoveryCode';
1730+
const links = this._generateSettingLinks(message, templateName);
1731+
const [time, date] = this._constructLocalTimeString(
1732+
message.timeZone,
1733+
message.acceptLanguage
1734+
);
1735+
1736+
const headers = {
1737+
'X-Link': links.link,
1738+
};
1739+
1740+
return this.send({
1741+
...message,
1742+
headers,
1743+
template: templateName,
1744+
templateValues: {
1745+
date,
1746+
device: this._formatUserAgentInfo(message),
1747+
privacyUrl: links.privacyUrl,
1748+
link: links.link,
1749+
resetLink: links.resetLink,
1750+
resetLinkAttributes: links.resetLinkAttributes,
1751+
supportLinkAttributes: links.supportLinkAttributes,
1752+
supportUrl: links.supportUrl,
1753+
time,
1754+
},
1755+
});
1756+
};
1757+
16991758
Mailer.prototype.postAddAccountRecoveryEmail = function (message) {
17001759
log.trace('mailer.postAddAccountRecoveryEmail', {
17011760
email: message.email,

packages/fxa-auth-server/lib/senders/emails/partials/automatedEmailResetPassword/en.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ automated-email-reset = This is an automated email; if you did not authorize thi
22
For more information, please visit <a data-l10n-name="supportLink">{ -brand-mozilla } Support</a>.
33
# Variables:
44
# $resetLink (String) - Link to https://accounts.firefox.com/reset_password
5-
automated-email-reset-plaintext = If you did not change it, please reset your password now at { $resetLink }
5+
automated-email-reset-plaintext-v2 = If you did not authorize this action, please reset your password now at { $resetLink }
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
automated-email-reset-plaintext = "If you did not change it, please reset your password now at <%- resetLink %>"
1+
automated-email-reset-plaintext-v2 = "If you did not authorize this action, please reset your password now at <%- resetLink %>"

packages/fxa-auth-server/lib/senders/emails/templates/_versions.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
"postAddRecoveryPhone": 1,
5050
"postChangeRecoveryPhone": 1,
5151
"postRemoveRecoveryPhone": 1,
52+
"postSigninRecoveryPhone": 1,
53+
"postSigninRecoveryCode": 1,
5254
"cadReminderFirst": 3,
5355
"cadReminderSecond": 3,
5456
"subscriptionAccountReminderFirst": 3,

packages/fxa-auth-server/lib/senders/emails/templates/postAddRecoveryPhone/en.ftl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
postAddRecoveryPhone-subject = Recovery phone added
2+
postAddRecoveryPhone-preview = Account protected by two-step authentication
23
postAddRecoveryPhone-title = You created a recovery phone number
34
# Variables:
45
# $maskedLastFourPhoneNumber (String) - A bullet point mask with the last four digits of the user's phone number, e.g. ••••••1234

packages/fxa-auth-server/lib/senders/emails/templates/postAddRecoveryPhone/includes.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,9 @@
66
"action": {
77
"id": "postAddRecoveryPhone-action",
88
"message": "Manage account"
9+
},
10+
"preview": {
11+
"id": "postAddRecoveryPhone-preview",
12+
"message": "Account protected by two-step authentication"
913
}
1014
}

packages/fxa-auth-server/lib/senders/emails/templates/postAddRecoveryPhone/index.stories.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ const createStory = storyWithProps(
2525
}
2626
);
2727

28-
export const PostChangePrimary = createStory();
28+
export const PostAddRecoveryPhone = createStory();

packages/fxa-auth-server/lib/senders/emails/templates/postAddRecoveryPhone/index.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ postAddRecoveryPhone-description = "You added <%- maskedLastFourPhoneNumber %> a
55
postAddRecoveryPhone-how-protect-plaintext = "How this protects your account:"
66
<%- twoFactorSupportLink %>
77

8-
postAddRecoveryPhone-from-device = "You enabled it from:"
8+
postAddRecoveryPhone-enabled-device = "You enabled it from:"
99
<%- include('/partials/userInfo/index.txt') %>
1010

1111
<%- include('/partials/manageAccount/index.txt') %>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
postChangeRecoveryPhone-subject = Recovery phone updated
2+
postChangeRecoveryPhone-preview = Account protected by two-step authentication
23
postChangeRecoveryPhone-title = You changed your recovery phone
34
postChangeRecoveryPhone-description = You now have a new recovery phone. Your previous phone number was deleted.
45
postChangeRecoveryPhone-requested-device = You requested it from:

0 commit comments

Comments
 (0)