diff --git a/src/components/navbar.tsx b/src/components/navbar.tsx index eec7008..cdb9874 100644 --- a/src/components/navbar.tsx +++ b/src/components/navbar.tsx @@ -32,17 +32,18 @@ export function NavBar() { - - + + Kneipolympics diff --git a/src/contexts/appwrite.tsx b/src/contexts/appwrite.tsx index e4069bb..a6c93f0 100644 --- a/src/contexts/appwrite.tsx +++ b/src/contexts/appwrite.tsx @@ -13,7 +13,9 @@ type Props = PropsWithChildren; export function AppwriteContextProvider({ children }: Props) { const client = new Client(); - client.setProject("67257b8d001f6f36d0be"); + client + .setEndpoint("https://cloud.appwrite.io/v1") + .setProject("67257b8d001f6f36d0be"); const value = { client, diff --git a/src/contexts/auth.tsx b/src/contexts/auth.tsx index 7bbf111..561881e 100644 --- a/src/contexts/auth.tsx +++ b/src/contexts/auth.tsx @@ -1,6 +1,7 @@ import { createContext, PropsWithChildren, + useCallback, useEffect, useMemo, useState, @@ -28,7 +29,21 @@ export function AuthContextProvider({ children }: PropsWithChildren) { Models.User | undefined >(); + const verifyUser = useCallback(async () => { + const params = new URLSearchParams(window.location.search); + const userId = params.get("userId"); + const secret = params.get("secret"); + + if (!(userId && secret)) { + return; + } + + await account.updateVerification(userId, secret).catch(() => {}); + }, [account]); + useEffect(() => { + verifyUser(); + account .getSession("current") .then((session) => { @@ -41,7 +56,7 @@ export function AuthContextProvider({ children }: PropsWithChildren) { .catch(() => account.deleteSession("current")); }) .catch(() => {}); - }, [account]); + }, [account, verifyUser]); async function login(email: string, password: string): Promise { const session = await account.createEmailPasswordSession(email, password); @@ -76,6 +91,9 @@ export function AuthContextProvider({ children }: PropsWithChildren) { name: string, ): Promise { await account.create(ID.unique(), email, password, name); + await account.createEmailPasswordSession(email, password); + await account.createVerification(window.location.origin.toString()); + await account.deleteSession("current"); } const value = {