diff --git a/apps/client/src/app.d.ts b/apps/client/src/app.d.ts index 2096f5b..792f3d4 100644 --- a/apps/client/src/app.d.ts +++ b/apps/client/src/app.d.ts @@ -13,7 +13,6 @@ declare global { type DatabaseUserAttributes = { email?: string; github_username?: string; - username?: string; }; type DatabaseSessionAttributes = Record; } diff --git a/apps/client/src/lib/server/lucia.ts b/apps/client/src/lib/server/lucia.ts index 74bb404..2179e19 100644 --- a/apps/client/src/lib/server/lucia.ts +++ b/apps/client/src/lib/server/lucia.ts @@ -25,6 +25,7 @@ export const auth = lucia({ getUserAttributes: (data) => { return { github_username: data.github_username, + email: data.email, }; }, }); diff --git a/apps/client/src/routes/+page.server.ts b/apps/client/src/routes/+page.server.ts index 03052d9..496c9a0 100644 --- a/apps/client/src/routes/+page.server.ts +++ b/apps/client/src/routes/+page.server.ts @@ -3,7 +3,7 @@ import { fail, redirect } from "@sveltejs/kit"; import type { PageServerLoad, Actions } from "./$types"; export const load: PageServerLoad = async ({ locals }) => { - const session = await locals.auth.validate() + const session = await locals.auth.validate(); console.log("session from home", session); // // const { session, user } = validate()? // const session = await locals.auth.validate(); @@ -15,11 +15,11 @@ export const load: PageServerLoad = async ({ locals }) => { }; export const actions: Actions = { - logout: async ({ locals }) => { - const session = await locals.auth.validate(); - if (!session) return fail(401); - await auth.invalidateSession(session.sessionId); // invalidate session - locals.auth.setSession(null); // remove cookie - throw redirect(302, "/login"); // redirect to login page - } -}; \ No newline at end of file + logout: async ({ locals }) => { + const session = await locals.auth.validate(); + if (!session) return fail(401); + await auth.invalidateSession(session.sessionId); // invalidate session + locals.auth.setSession(null); // remove cookie + throw redirect(302, "/login"); // redirect to login page + }, +}; diff --git a/apps/client/src/routes/+page.svelte b/apps/client/src/routes/+page.svelte index e2b9b78..08e3c91 100644 --- a/apps/client/src/routes/+page.svelte +++ b/apps/client/src/routes/+page.svelte @@ -1,5 +1,4 @@