-
Notifications
You must be signed in to change notification settings - Fork 191
feat: implement email verification flow with route guard and modal #2398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
120187e
45cf897
ff76c63
e84df2d
bfdbc38
3f7fbf8
d5ef69c
d4b9066
0f9c48d
860cd40
ccaae73
528e43b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
<script lang="ts"> | ||
import Sidebar from '$lib/components/sidebar.svelte'; | ||
import Navbar from '$lib/components/navbar.svelte'; | ||
import SendVerificationEmailModal from '$lib/components/account/sendVerificationEmailModal.svelte'; | ||
import { writable } from 'svelte/store'; | ||
ItzNotABug marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
import { invalidate } from '$app/navigation'; | ||
import { goto } from '$app/navigation'; | ||
import { onMount } from 'svelte'; | ||
import { base } from '$app/paths'; | ||
import { Dependencies } from '$lib/constants'; | ||
import { page } from '$app/state'; | ||
ItzNotABug marked this conversation as resolved.
Show resolved
Hide resolved
|
||
let sideBarIsOpen = writable(false); | ||
let showAccountMenu = writable(false); | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
|
||
let project: any = { | ||
$id: 'verify-email-project', | ||
region: 'us-east-1', | ||
name: 'Verify Email Project' | ||
}; | ||
let avatar = '/images/default-avatar.png'; | ||
let progressCard = { | ||
title: 'Get started', | ||
percentage: 33 | ||
}; | ||
let navbarProps = { | ||
logo: { | ||
src: '/images/appwrite-logo-light.svg', | ||
alt: 'Appwrite Logo' | ||
}, | ||
avatar: avatar, | ||
organizations: [], | ||
currentProject: project | ||
}; | ||
let showVerificationModal = $state(!page.data.account?.emailVerification); | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
$effect(() => { | ||
if (page.data.account?.emailVerification) { | ||
checkEmailVerification(); | ||
} | ||
}); | ||
ItzNotABug marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
async function checkEmailVerification() { | ||
if (page.data.account?.emailVerification) { | ||
await goto(`${base}/`); | ||
} | ||
} | ||
ItzNotABug marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
ItzNotABug marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
onMount(() => { | ||
if (!page.data.account) { | ||
goto(`${base}/login`); | ||
return; | ||
} | ||
// If email is already verified, redirect immediately | ||
if (page.data.account?.emailVerification) { | ||
checkEmailVerification(); | ||
return; | ||
} | ||
ItzNotABug marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
const interval = setInterval(async () => { | ||
await invalidate(Dependencies.ACCOUNT); | ||
checkEmailVerification(); | ||
}, 2000); | ||
ItzNotABug marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
return () => clearInterval(interval); | ||
}); | ||
</script> | ||
|
||
<svelte:head> | ||
<title>Verify Email - Appwrite Console</title> | ||
</svelte:head> | ||
|
||
<div class="verify-email-page"> | ||
<Navbar | ||
{...navbarProps} | ||
bind:sideBarIsOpen={$sideBarIsOpen} | ||
bind:showAccountMenu={$showAccountMenu} /> | ||
|
||
<Sidebar | ||
bind:sideBarIsOpen={$sideBarIsOpen} | ||
bind:showAccountMenu={$showAccountMenu} | ||
{project} | ||
{avatar} | ||
{progressCard} | ||
state="open" /> | ||
|
||
<!-- email verification modal --> | ||
<SendVerificationEmailModal | ||
bind:show={showVerificationModal} | ||
email={page.data.account?.email} /> | ||
</div> | ||
ItzNotABug marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
<style lang="scss"> | ||
.verify-email-page { | ||
display: flex; | ||
min-height: 100vh; | ||
position: relative; | ||
width: 100%; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
.main-content { | ||
flex: 1; | ||
padding: 2rem; | ||
margin-left: 190px; | ||
min-height: 100vh; | ||
} | ||
:global(.verify-email-page .sidebar) { | ||
HarshMN2345 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
position: fixed !important; | ||
left: 0 !important; | ||
top: 0 !important; | ||
height: 100vh !important; | ||
z-index: 1000 !important; | ||
filter: blur(4px); | ||
opacity: 0.6; | ||
} | ||
/* Blur the navbar */ | ||
:global(.verify-email-page .navbar), | ||
:global(.verify-email-page [data-pink-navbar]), | ||
:global(.verify-email-page header) { | ||
filter: blur(2px); | ||
opacity: 0.4; | ||
z-index: 1; | ||
} | ||
/* ensure modal is above everything and not blurred */ | ||
:global(.verify-email-page .email-verification-scrim) { | ||
z-index: 9999 !important; | ||
filter: none !important; | ||
opacity: 1 !important; | ||
} | ||
:global(.verify-email-page .email-verification-scrim *) { | ||
filter: none !important; | ||
opacity: 1 !important; | ||
} | ||
</style> |
Uh oh!
There was an error while loading. Please reload this page.