From c5ed79b0bbcfa18fd7925d2b041ce3c4717dd1a3 Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Fri, 19 Apr 2024 18:18:41 -0700 Subject: [PATCH] feat(mfa): show more MFA methods & recovery options for console account --- src/lib/actions/analytics.ts | 5 + src/routes/console/account/deleteMfa.svelte | 10 +- src/routes/console/account/mfa.svelte | 128 ++-------- .../console/account/mfaRecoveryCodes.svelte | 64 +++++ .../console/account/mfaRegenerateCodes.svelte | 48 ++++ src/routes/console/account/store.ts | 5 +- src/routes/console/account/updateMfa.svelte | 228 +++++++++++++----- 7 files changed, 320 insertions(+), 168 deletions(-) create mode 100644 src/routes/console/account/mfaRecoveryCodes.svelte create mode 100644 src/routes/console/account/mfaRegenerateCodes.svelte diff --git a/src/lib/actions/analytics.ts b/src/lib/actions/analytics.ts index 4c9cb3be8..b82ad351b 100644 --- a/src/lib/actions/analytics.ts +++ b/src/lib/actions/analytics.ts @@ -151,7 +151,12 @@ export enum Submit { AccountDelete = 'submit_account_delete', AccountDeleteSession = 'submit_account_delete_session', AccountDeleteAllSessions = 'submit_account_delete_all_sessions', + AccountUpdateMfa = 'submit_account_update_mfa', + AccountAuthenticatorCreate = 'submit_account_authenticator_create', + AccountAuthenticatorUpdate = 'submit_account_authenticator_update', AccountAuthenticatorDelete = 'submit_account_authenticator_delete', + AccountRecoveryCodesCreate = 'submit_account_recovery_codes_create', + AccountRecoveryCodesUpdate = 'submit_account_recovery_codes_update', UserCreate = 'submit_user_create', UserDelete = 'submit_user_delete', UserUpdateEmail = 'submit_user_update_email', diff --git a/src/routes/console/account/deleteMfa.svelte b/src/routes/console/account/deleteMfa.svelte index 15d0b629f..9d01dcfed 100644 --- a/src/routes/console/account/deleteMfa.svelte +++ b/src/routes/console/account/deleteMfa.svelte @@ -15,7 +15,7 @@ let code: string; let error: string; - async function deleteProvider() { + async function deleteAuthenticator() { try { await sdk.forConsole.account.deleteMfaAuthenticator(AuthenticatorType.Totp, code); await invalidate(Dependencies.ACCOUNT); @@ -41,18 +41,14 @@ -

- Deleting the authentication method will disable multi-factor authentication for your - account. To re-enable it, you'll need to add a new authentication method. -

Enter the 6-digit verification code generated by your authenticator app to continue.

- + diff --git a/src/routes/console/account/mfa.svelte b/src/routes/console/account/mfa.svelte index 53ada1479..5fa0c8d4a 100644 --- a/src/routes/console/account/mfa.svelte +++ b/src/routes/console/account/mfa.svelte @@ -1,25 +1,24 @@ + onSubmit={verifyAuthenticator} + {error}> {#key showSetup} -

- Install an authenticator app on your mobile device, open it and scan the provided QR - code or enter it manually. -

{#if step === 1} +

+ Install an authenticator app on your mobile device, open it and scan the provided QR + code or enter it manually. +

{#await addAuthenticator()}
@@ -69,26 +63,12 @@ or
- - - -
- -
- {#key copyParent} - - - {/key} -
-
+
{/await} {:else} @@ -108,68 +88,6 @@ - - {#if type && codes} - {@const formattedBackupCodes = codes.recoveryCodes.join('\n')} - - - It is highly recommended to securely store your recovery codes - -

- Use security codes for emergency sign-ins in case you've lost access to your mobile - device. Each recovery code can only be used once, but you can re-generate a new set - of 6 codes anytime. -

-
-
-
    -
  • - -
  • -
  • - - - -
  • -
-
- - - {#each codes.recoveryCodes as code} - - - {code} - - - - - - - {/each} - -
- {/if} - - - -
-