Compare commits
2 commits
c514bc27dc
...
5ebcbb0ced
Author | SHA1 | Date | |
---|---|---|---|
5ebcbb0ced | |||
c5d3a1ea09 |
2 changed files with 78 additions and 7 deletions
|
@ -1,10 +1,23 @@
|
|||
<script>
|
||||
import { logOut, loggedInUser } from "./appwrite";
|
||||
|
||||
|
||||
import { account, logOut, loggedInUser } from "./appwrite";
|
||||
</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}
|
||||
<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}
|
||||
|
|
|
@ -1,3 +1,61 @@
|
|||
<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>
|
||||
|
||||
<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>
|
||||
|
|
Loading…
Reference in a new issue