Skip to content

Commit fccbab1

Browse files
Merge pull request #19943 from mozilla/FXA-12790
feat(settings): enable 2FA setup for passwordless accounts
2 parents 3c8bf1b + 21afdbb commit fccbab1

6 files changed

Lines changed: 9 additions & 71 deletions

File tree

packages/fxa-settings/src/components/Settings/UnitRowTwoStepAuth/index.stories.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,6 @@ export const TFADisabled = () =>
4343
backupCodes: { count: 0 },
4444
});
4545

46-
export const DisabledNoPassword = () =>
47-
createSubject({
48-
hasPassword: false,
49-
totp: { enabled: false },
50-
backupCodes: { count: 0 },
51-
});
52-
5346
export const TwoFAEnabledWithBackupCodesNoBackupPhone = () =>
5447
createSubject({
5548
recoveryPhone: { exists: false, phoneNumber: null, available: true },

packages/fxa-settings/src/components/Settings/UnitRowTwoStepAuth/index.test.tsx

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -82,29 +82,6 @@ describe('UnitRowTwoStepAuth', () => {
8282
).toContain('Add');
8383
});
8484

85-
it('renders disabled state when account has no password', async () => {
86-
renderWithRouter(
87-
createSubject({
88-
hasPassword: false,
89-
totp: { exists: false, verified: false },
90-
backupCodes: { hasBackupCodes: false, count: 0 },
91-
})
92-
);
93-
94-
const mainButton = await screen.findByText('Add');
95-
expect(mainButton).toBeDisabled();
96-
expect(mainButton).toHaveAttribute(
97-
'title',
98-
'Set a password to sync and use certain account security features.'
99-
);
100-
expect(
101-
screen.getByTestId('two-step-unit-row-header-value').textContent
102-
).toContain('Disabled');
103-
expect(
104-
screen.queryByTestId('backup-authentication-codes-sub-row')
105-
).not.toBeInTheDocument();
106-
});
107-
10885
it('renders view as not enabled after disabling TOTP', async () => {
10986
const user = userEvent.setup();
11087
const disableTwoStepAuthMock = jest.fn().mockResolvedValue(true);

packages/fxa-settings/src/components/Settings/UnitRowTwoStepAuth/index.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,6 @@ export const UnitRowTwoStepAuth = () => {
160160
headerId="two-step-authentication"
161161
prefixDataTestId="two-step"
162162
{...conditionalUnitRowProps}
163-
disabled={!account.hasPassword}
164-
disabledReason={ftlMsgResolver.getMsg(
165-
'security-set-password',
166-
'Set a password to sync and use certain account security features.'
167-
)}
168163
subRows={getSubRows()}
169164
>
170165
{exists && verified ? (

packages/fxa-settings/src/components/Settings/UnitRowTwoStepAuth/mocks.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export const createSubject = (
1313
settingsOverrides = {}
1414
) => {
1515
const account = {
16-
hasPassword: true,
1716
backupCodes: { hasBackupCodes: true, count: 3 },
1817
totp: { exists: true, verified: true },
1918
recoveryPhone: {

packages/fxa-settings/src/components/Settings/index.test.tsx

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -391,12 +391,12 @@ describe('Settings App', () => {
391391
{
392392
pageName: 'Page2faChange',
393393
route: '/two_step_authentication/change',
394-
hasPassword: true,
394+
hasPassword: false,
395395
},
396396
{
397397
pageName: 'PageSecondaryEmailAdd',
398398
route: '/emails',
399-
hasPassword: true,
399+
hasPassword: false,
400400
},
401401
{
402402
pageName: 'PageSecondaryEmailVerify',
@@ -406,7 +406,7 @@ describe('Settings App', () => {
406406
{
407407
pageName: 'Page2faReplaceBackupCodes',
408408
route: '/two_step_authentication/replace_codes',
409-
hasPassword: true,
409+
hasPassword: false,
410410
},
411411
{
412412
pageName: 'PageRecoveryPhoneSetup',
@@ -426,12 +426,12 @@ describe('Settings App', () => {
426426
{
427427
pageName: 'PageRecoveryPhoneRemove',
428428
route: '/recovery_phone/remove',
429-
hasPassword: true,
429+
hasPassword: false,
430430
},
431431
{
432432
pageName: 'Page2faSetup',
433433
route: '/two_step_authentication',
434-
hasPassword: true,
434+
hasPassword: false,
435435
},
436436
];
437437

@@ -491,18 +491,6 @@ describe('Settings App', () => {
491491
expect(history.location.pathname).toBe('/settings');
492492
});
493493

494-
it('redirects two-step authentication page', async () => {
495-
await history.navigate(SETTINGS_PATH + '/two_step_authentication');
496-
expect(history.location.pathname).toBe('/settings');
497-
});
498-
499-
it('redirects Page2faReplaceRecoveryCodes', async () => {
500-
await history.navigate(
501-
SETTINGS_PATH + '/two_step_authentication/replace_codes'
502-
);
503-
expect(history.location.pathname).toBe('/settings');
504-
});
505-
506494
it('redirects ChangePassword', async () => {
507495
await history.navigate(SETTINGS_PATH + '/change_password');
508496
expect(history.location.pathname).toBe('/settings/create_password');

packages/fxa-settings/src/components/Settings/index.tsx

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -196,19 +196,15 @@ export const Settings = ({
196196
<PageSettings path="/" {...{ integration }} />
197197
<PageDisplayName path="/display_name" />
198198
<PageAvatar path="/avatar" />
199-
{account.hasPassword ? (
200-
<MfaGuardPageRecoveryKeyCreate path="/account_recovery" />
201-
) : (
202-
<Redirect from="/account_recovery" to="/settings" noThrow />
203-
)}
204199
{/* MfaPageCreatePassword internally redirects to /change_password if password exists */}
205200
<MfaPageCreatePassword path="/create_password" />
201+
<MfaGuardPage2faSetup path="/two_step_authentication" />
202+
<MfaGuardPage2faChange path="/two_step_authentication/change" />
203+
<MfaGuardPage2faReplaceBackupCodes path="/two_step_authentication/replace_codes" />
206204
{account.hasPassword ? (
207205
<>
206+
<MfaGuardPageRecoveryKeyCreate path="/account_recovery" />
208207
<MfaGuardedPageChangePassword path="/change_password" />
209-
<MfaGuardPage2faSetup path="/two_step_authentication" />
210-
<MfaGuardPage2faChange path="/two_step_authentication/change" />
211-
<MfaGuardPage2faReplaceBackupCodes path="/two_step_authentication/replace_codes" />
212208
</>
213209
) : (
214210
<>
@@ -218,16 +214,6 @@ export const Settings = ({
218214
noThrow
219215
/>
220216
<Redirect from="/account_recovery" to="/settings" noThrow />
221-
<Redirect
222-
from="/two_step_authentication"
223-
to="/settings"
224-
noThrow
225-
/>
226-
<Redirect
227-
from="/two_step_authentication/replace_codes"
228-
to="/settings"
229-
noThrow
230-
/>
231217
</>
232218
)}
233219
<MfaGuardPageSecondaryEmailAdd path="/emails" />

0 commit comments

Comments
 (0)