diff --git a/src/lib/components/account/sendVerificationEmailModal.svelte b/src/lib/components/account/sendVerificationEmailModal.svelte index 100ff6309..c6e7ab906 100644 --- a/src/lib/components/account/sendVerificationEmailModal.svelte +++ b/src/lib/components/account/sendVerificationEmailModal.svelte @@ -9,7 +9,6 @@ import Link from '$lib/elements/link.svelte'; import { Card, Layout, Typography } from '@appwrite.io/pink-svelte'; import { Dependencies } from '$lib/constants'; - import { onDestroy } from 'svelte'; import { resolve } from '$app/paths'; import ResendCooldown from '$lib/components/resendCooldown.svelte'; @@ -53,8 +52,6 @@ creating = false; } } - - onDestroy(() => {});
diff --git a/src/lib/components/resendCooldown.svelte b/src/lib/components/resendCooldown.svelte index f390f0664..26118ac21 100644 --- a/src/lib/components/resendCooldown.svelte +++ b/src/lib/components/resendCooldown.svelte @@ -4,12 +4,12 @@ import { Link } from '@appwrite.io/pink-svelte'; let { - storageKey = 'resend_cooldown_default', + storageKey, seconds = 60, disabled = $bindable(false), onResend }: { - storageKey?: string; + storageKey: string; seconds?: number; disabled?: boolean; onResend: () => Promise | void; diff --git a/src/routes/(public)/(guest)/login/email-otp/+page.svelte b/src/routes/(public)/(guest)/login/email-otp/+page.svelte index 50048c67f..2b1a42a2f 100644 --- a/src/routes/(public)/(guest)/login/email-otp/+page.svelte +++ b/src/routes/(public)/(guest)/login/email-otp/+page.svelte @@ -12,19 +12,17 @@ import { Layout, Typography } from '@appwrite.io/pink-svelte'; import { page } from '$app/state'; import ResendCooldown from '$lib/components/resendCooldown.svelte'; + import { ID } from '@appwrite.io/console'; - let otpCode: string = ''; - let disabled: boolean = false; - let email: string = ''; - let userId: string = ''; + let { data } = $props(); - export let data; + let otpCode = $state(''); + let disabled = $state(false); + let email = $derived(page.url.searchParams.get('email') || ''); + let userId = $derived(page.url.searchParams.get('userId') || ''); - // Get email and userId from URL params - $: email = page.url.searchParams.get('email') || ''; - $: userId = page.url.searchParams.get('userId') || ''; - - async function verifyOTP() { + async function verifyOTP(event) { + event.preventDefault(); try { disabled = true; // Use createSession with the userId from createEmailToken @@ -71,7 +69,7 @@ try { disabled = true; const sessionToken = await sdk.forConsole.account.createEmailToken({ - userId: 'unique', + userId: ID.unique(), email: email }); userId = sessionToken.userId; @@ -102,7 +100,7 @@ We sent a 6-digit code to {email} -
+