Compare commits

..

2 commits

Author SHA1 Message Date
5ebcbb0ced
linting 2023-11-01 23:41:48 +00:00
c5d3a1ea09
email verification 2023-11-01 23:41:39 +00:00
2 changed files with 78 additions and 7 deletions

View file

@ -1,10 +1,23 @@
<script> <script>
import { logOut, loggedInUser } from "./appwrite"; import { account, logOut, loggedInUser } from "./appwrite";
</script> </script>
<div class="">Welcome, {loggedInUser.name} <a href="#" class="text-blue-400" on:click={logOut}>Log out</a></div> <div class="">
Welcome, {loggedInUser.name}
<a href="#" class="text-blue-400" on:click={logOut}>Log out</a>
</div>
{#if !loggedInUser.emailVerification} {#if !loggedInUser.emailVerification}
<div class="">You have not verified your email address yet</div> <div class="">
You have not verified your email address yet <a
href="#"
class="text-blue-400"
on:click={() =>
account.createVerification(
window.location.protocol +
"//" +
window.location.host +
"/register/emailVerify",
)}>Resend verification email</a
>
</div>
{/if} {/if}

View file

@ -1,3 +1,61 @@
<script> <script>
import { navigate } from "svelte-navigator/src/history";
import { account, loggedInUser, teams } from "../lib/appwrite";
import Header from "../lib/Header.svelte";
import { Link } from "svelte-navigator";
const searchParams = new URLSearchParams(document.location.search);
let confirmed = false;
let alreadyConfirmed = false;
if (
loggedInUser !== null &&
searchParams.get("userId") == loggedInUser["$id"]
) {
account
.updateVerification(
searchParams.get("userId"),
searchParams.get("secret"),
)
.then((r) => {
console.log(r);
confirmed = true;
})
.catch((r) => {
if (r.type == "user_invalid_token") {
alreadyConfirmed = true;
}
});
}
</script> </script>
<main class="container m-5">
{#if loggedInUser !== null}
<Header />
{/if}
{#if loggedInUser == null}
Please log in to confirm your email address <Link
class="text-blue-400"
to="/login?redirect_uri={encodeURIComponent(window.location.href)}"
>Log in</Link
>
{/if}
{#if loggedInUser !== null && searchParams.get("userId") !== loggedInUser["$id"]}
You can't verify your email for a different account. Please log out and log
back into the correct user.
{/if}
{#if confirmed == true}
Your email address has been successfully confirmed! <Link to="/"
>Go home</Link
>
{/if}
{#if alreadyConfirmed == true}
This verification link is invalid. You may already used it, or it may have
expired. <Link to="/">Go home</Link>
{/if}
</main>