-
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
120187e
feat: implement email verification flow with route guard and modal
HarshMN2345 45cf897
build error fix
HarshMN2345 ff76c63
lint issue : any
HarshMN2345 e84df2d
code rabbit suggestion:
HarshMN2345 bfdbc38
use page from app/state and removed div added notifs
HarshMN2345 3f7fbf8
proper scss
HarshMN2345 d5ef69c
use realtime account subscription with 10s fallback
HarshMN2345 d4b9066
always invalidate and redirect to login
HarshMN2345 0f9c48d
Merge branch 'main' into feat-SER-166-Block-For-Email-Verification
ItzNotABug 860cd40
update: refactor.
ItzNotABug ccaae73
Merge branch 'main' into feat-SER-166-Block-For-Email-Verification
ItzNotABug 528e43b
Update src/lib/components/account/sendVerificationEmailModal.svelte
HarshMN2345 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
<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 type { PageData } from './$types'; | ||
|
||
let { data }: { data: PageData } = $props(); | ||
|
||
let sideBarIsOpen = writable(false); | ||
let showAccountMenu = writable(false); | ||
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(!data.user?.emailVerification); | ||
|
||
$effect(() => { | ||
if (data.user?.emailVerification) { | ||
checkEmailVerification(); | ||
} | ||
}); | ||
|
||
async function checkEmailVerification() { | ||
if (data.user?.emailVerification) { | ||
await goto(`${base}/`); | ||
} | ||
} | ||
|
||
onMount(() => { | ||
if (!data.user) { | ||
goto(`${base}/login`); | ||
return; | ||
} | ||
|
||
// If email is already verified, redirect immediately | ||
if (data.user?.emailVerification) { | ||
checkEmailVerification(); | ||
return; | ||
} | ||
|
||
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" /> | ||
|
||
<div class="main-content"> | ||
<!-- Main content area --> | ||
</div> | ||
HarshMN2345 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
<!-- email verification modal --> | ||
<SendVerificationEmailModal bind:show={showVerificationModal} email={data.user?.email} /> | ||
</div> | ||
|
||
<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; | ||
} | ||
|
||
.main-content { | ||
filter: blur(4px); | ||
opacity: 0.6; | ||
} | ||
|
||
/* 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type { PageLoad } from './$types'; | ||
|
||
export const load: PageLoad = async ({ parent }) => { | ||
const { account } = await parent(); | ||
|
||
return { | ||
user: account | ||
}; | ||
}; | ||
HarshMN2345 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.