fix: enums

This commit is contained in:
Torsten Dittmann
2024-02-09 09:49:27 +01:00
parent e65925d180
commit 5e9ce9e12f
5 changed files with 17 additions and 7 deletions
+2 -1
View File
@@ -6,6 +6,7 @@
import { Button } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import { AuthenticatorProvider } from '@appwrite.io/console';
export let showDelete = false;
@@ -13,7 +14,7 @@
async function deleteProvider() {
try {
await sdk.forConsole.account.deleteAuthenticator('totp', code);
await sdk.forConsole.account.deleteAuthenticator(AuthenticatorProvider.Totp, code);
await invalidate(Dependencies.ACCOUNT);
showDelete = false;
addNotification({
+3 -3
View File
@@ -8,7 +8,7 @@
import { Table, TableBody, TableCell, TableRow } from '$lib/elements/table';
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import type { Models } from '@appwrite.io/console';
import { AuthenticatorFactor, type Models } from '@appwrite.io/console';
export let showSetup = false;
export let showRecoveryCodes = false;
@@ -16,14 +16,14 @@
let code: string;
let provider: Models.MfaProvider = null;
async function addAuthenticator(): Promise<URL> {
provider = await sdk.forConsole.account.addAuthenticator('totp');
provider = await sdk.forConsole.account.addAuthenticator(AuthenticatorFactor.Totp);
return sdk.forConsole.avatars.getQR(provider.uri, 192 * 2);
}
async function verifyAuthenticator() {
try {
await sdk.forConsole.account.verifyAuthenticator('totp', code);
await sdk.forConsole.account.verifyAuthenticator(AuthenticatorFactor.Totp, code);
await invalidate(Dependencies.ACCOUNT);
showSetup = false;
showRecoveryCodes = true;
@@ -26,7 +26,15 @@ type ProvidersMap = {
configure: {
label: string;
name: string;
type: 'text' | 'password' | 'phone' | 'email' | 'domain' | 'file' | 'switch' | 'select';
type:
| 'text'
| 'password'
| 'phone'
| 'email'
| 'domain'
| 'file'
| 'switch'
| 'select';
placeholder?: string;
description?: string;
popover?: string[];
@@ -9,7 +9,7 @@
async function beforeSubmit() {}
const createMessage = (providerText:string) => {
const createMessage = (providerText: string) => {
const vowels = ['a', 'e', 'i', 'o', 'u'];
const firstLetter = providerText.toLowerCase().charAt(0);
const lastLetter = providerText.toLowerCase().charAt(providerText.length - 1);
+2 -1
View File
@@ -8,13 +8,14 @@
import { Dependencies } from '$lib/constants';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { page } from '$app/stores';
import { AuthenticatorProvider } from '@appwrite.io/console';
let code: string, disabled: boolean;
async function verify() {
try {
disabled = true;
const challenge = await sdk.forConsole.account.createChallenge('totp');
const challenge = await sdk.forConsole.account.createChallenge(AuthenticatorProvider.Totp);
await sdk.forConsole.account.updateChallenge(challenge.$id, code);
await invalidate(Dependencies.ACCOUNT);
trackEvent(Submit.AccountCreate);