Skip to content

Commit cdb8fe3

Browse files
committed
fix(auth): Send email when changing recovery phone
Because: * No email was sent when changing recovery phone This commit: * Correct the mailer function name Closes #FXA-11822
1 parent f6d01d6 commit cdb8fe3

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

packages/fxa-auth-server/lib/routes/recovery-phone.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,6 @@ class RecoveryPhoneHandler {
531531
}
532532

533533
async changePhoneNumber(request: AuthRequest) {
534-
// need to check first that there is an existing phone number
535534
const { uid } = request.auth.credentials as SessionTokenAuthCredential;
536535

537536
const { code } = request.payload as unknown as {
@@ -597,11 +596,17 @@ class RecoveryPhoneHandler {
597596

598597
const { phoneNumber, nationalFormat } =
599598
await this.recoveryPhoneService.hasConfirmed(uid);
599+
600+
recordSecurityEvent('account.recovery_phone_replace_complete', {
601+
db: this.db,
602+
request,
603+
});
604+
600605
const { acceptLanguage, geo, ua } = request.app;
601606
const account = await this.db.account(uid);
602607

603608
try {
604-
await this.mailer.postChangeRecoveryPhoneEmail(account.emails, account, {
609+
await this.mailer.sendPostChangeRecoveryPhoneEmail(account.emails, account, {
605610
acceptLanguage,
606611
timeZone: geo.timeZone,
607612
uaBrowser: ua.browser,
@@ -611,11 +616,6 @@ class RecoveryPhoneHandler {
611616
uaDeviceType: ua.deviceType,
612617
uid,
613618
});
614-
615-
recordSecurityEvent('account.recovery_phone_replace_complete', {
616-
db: this.db,
617-
request,
618-
});
619619
} catch (error) {
620620
// log error, but don't throw
621621
// user should be allowed to proceed if email or security event fails

packages/fxa-auth-server/test/local/routes/recovery-phone.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ describe('/recovery_phone', () => {
694694
});
695695

696696
it('does not reject if email does not send', async () => {
697-
mockMailer.postChangeRecoveryPhoneEmail = sinon.fake.returns(
697+
mockMailer.sendPostChangeRecoveryPhoneEmail = sinon.fake.returns(
698698
Promise.reject(new Error('BOOM'))
699699
);
700700

@@ -706,7 +706,7 @@ describe('/recovery_phone', () => {
706706
});
707707

708708
assert.isDefined(resp);
709-
assert.calledOnce(mockMailer.postChangeRecoveryPhoneEmail);
709+
assert.calledOnce(mockMailer.sendPostChangeRecoveryPhoneEmail);
710710
assert.deepEqual(resp, {
711711
status: 'success',
712712
phoneNumber,

packages/fxa-auth-server/test/mocks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ const MAILER_METHOD_NAMES = [
184184
'sendPostRemoveRecoveryPhoneEmail',
185185
'sendPostSigninRecoveryPhoneEmail',
186186
'sendPostSigninRecoveryCodeEmail',
187-
'postChangeRecoveryPhoneEmail',
187+
'sendPostChangeRecoveryPhoneEmail',
188188
];
189189

190190
const METRICS_CONTEXT_METHOD_NAMES = [

0 commit comments

Comments
 (0)