Skip to content

Commit e76f69a

Browse files
committed
fix(auth, settings): Use redis to store unconfirmed secondary email
Because: * We don't want to hold on to unconfirmed secondary emails * Let's use Redis to store the temporary entry and only add to db once verified This commit: * Update emails route handlers to use Redis * Add new error type * Update front end to handle the flow changes * Update tests Closes #FXA-12548
1 parent ec581fe commit e76f69a

File tree

16 files changed

+1282
-833
lines changed

16 files changed

+1282
-833
lines changed

packages/functional-tests/tests/settings/changeEmail.spec.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -216,21 +216,6 @@ test.describe('severity-1 #smoke', () => {
216216
await settings.secondaryEmail.deleteButton.click();
217217

218218
await expect(settings.alertBar).toHaveText(/successfully deleted/);
219-
220-
await settings.secondaryEmail.addButton.click();
221-
await secondaryEmail.emailTextbox.fill(newEmail);
222-
await secondaryEmail.submit();
223-
224-
// skip verification
225-
await settings.goto();
226-
227-
await expect(settings.secondaryEmail.unverifiedText).toHaveText(
228-
'unconfirmed'
229-
);
230-
231-
await settings.secondaryEmail.deleteButton.click();
232-
233-
await expect(settings.alertBar).toHaveText(/successfully deleted/);
234219
});
235220
});
236221
});
@@ -274,7 +259,7 @@ async function setNewPassword(
274259
oldPassword: string,
275260
newPassword: string,
276261
target: BaseTarget,
277-
email: string,
262+
email: string
278263
): Promise<void> {
279264
await settings.password.changeButton.click();
280265

packages/fxa-auth-server/config/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,8 +504,7 @@ const convictConf = convict({
504504
subscriptionSupportUrl: {
505505
doc: 'url to Mozilla subscription support page',
506506
format: String,
507-
default:
508-
'https://support.mozilla.org/products',
507+
default: 'https://support.mozilla.org/products',
509508
},
510509
redirectDomain: {
511510
doc: 'Domain that mail urls are allowed to redirect to',
@@ -1749,6 +1748,12 @@ const convictConf = convict({
17491748
format: 'duration',
17501749
env: 'SECONDARY_EMAIL_MIN_UNVERIFIED_ACCOUNT_TIME',
17511750
},
1751+
pendingTtlSeconds: {
1752+
doc: 'TTL in seconds for pending secondary email reservations (Redis)',
1753+
format: 'nat',
1754+
default: 3600,
1755+
env: 'SECONDARY_EMAIL_PENDING_TTL_SECONDS',
1756+
},
17521757
},
17531758
signinCodeSize: {
17541759
doc: 'signinCode size in bytes',

packages/fxa-auth-server/lib/error.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,7 @@ AppError.recoveryCodesAlreadyExist = () => {
583583
code: 400,
584584
error: 'Bad Request',
585585
errno: ERRNO.RECOVERY_CODES_ALREADY_EXISTS,
586-
message:
587-
'Recovery codes or a verified TOTP token already exist',
586+
message: 'Recovery codes or a verified TOTP token already exist',
588587
});
589588
};
590589

@@ -810,6 +809,15 @@ AppError.emailExists = () => {
810809
});
811810
};
812811

812+
AppError.emailInUseByAnotherAccount = () => {
813+
return new AppError({
814+
code: 400,
815+
error: 'Bad Request',
816+
errno: ERRNO.EMAIL_IN_USE_BY_ANOTHER_ACCOUNT,
817+
message: 'This email is already in use by another account.',
818+
});
819+
};
820+
813821
AppError.cannotDeletePrimaryEmail = () => {
814822
return new AppError({
815823
code: 400,

0 commit comments

Comments
 (0)