diff --git a/src/lib/images/qr2.svg b/src/lib/images/qr2.svg new file mode 100644 index 000000000..b106c2e2b --- /dev/null +++ b/src/lib/images/qr2.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/routes/console/account/mfa.svelte b/src/routes/console/account/mfa.svelte index 5f38068bd..53ada1479 100644 --- a/src/routes/console/account/mfa.svelte +++ b/src/routes/console/account/mfa.svelte @@ -2,21 +2,22 @@ import { invalidate } from '$app/navigation'; import { Submit, trackError } from '$lib/actions/analytics'; import { Modal, Output, Copy, Alert } from '$lib/components'; - import LoadingDots from '$lib/components/loadingDots.svelte'; import { Dependencies } from '$lib/constants'; import { Button, FormList, InputDigits } from '$lib/elements/forms'; import { Table, TableBody, TableCell, TableRow } from '$lib/elements/table'; import { addNotification } from '$lib/stores/notifications'; import { sdk } from '$lib/stores/sdk'; import { AuthenticatorType, type Models } from '@appwrite.io/console'; - + import QrFrame from '$lib/images/qr2.svg'; export let showSetup = false; export let showRecoveryCodes = false; let copyParent: HTMLElement; let code: string; let type: Models.MfaType = null; + let step = 1; let codes: Models.MfaRecoveryCodes = null; + async function addAuthenticator(): Promise { type = await sdk.forConsole.account.createMfaAuthenticator(AuthenticatorType.Totp); @@ -51,52 +52,59 @@ Install an authenticator app on your mobile device, open it and scan the provided QR code or enter it manually.

+ {#if step === 1} + {#await addAuthenticator()} +
+
+
+ {:then qr} +
+ MFA QR Code +
+ or - {#await addAuthenticator()} -
- -
- {:then qr} -
- MFA QR Code -
- or +
+ + -
- - - -
- -
-
+
+ +
{#key copyParent} - + {/key}
-
- {/await} - -
- - - - + {/await} + {:else} + + + + + {/if} {/key} - + {#if step === 1} + + {:else} + + {/if} @@ -163,6 +171,12 @@ diff --git a/src/routes/console/account/updateMfa.svelte b/src/routes/console/account/updateMfa.svelte index 140943222..28ebea5d5 100644 --- a/src/routes/console/account/updateMfa.svelte +++ b/src/routes/console/account/updateMfa.svelte @@ -88,5 +88,7 @@ - +{#if showSetup} + +{/if}