From 41f42eb2b4108fd056c2d438ff9f208c4bbf8d77 Mon Sep 17 00:00:00 2001 From: AlexBocken Date: Sun, 23 Jul 2023 12:29:41 +0200 Subject: [PATCH] get user from cookie, not locals --- src/routes/(main)/login/+page.server.ts | 6 ------ src/routes/(main)/register/+page.server.ts | 6 ------ src/routes/(main)/settings/+page.server.ts | 7 +++---- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/routes/(main)/login/+page.server.ts b/src/routes/(main)/login/+page.server.ts index f8ebd72..f900f9a 100644 --- a/src/routes/(main)/login/+page.server.ts +++ b/src/routes/(main)/login/+page.server.ts @@ -2,12 +2,6 @@ import { redirect } from "@sveltejs/kit" import type { Actions, PageServerLoad } from "./$types" import { error } from "@sveltejs/kit" -export const load: PageServerLoad = async ({ locals }) => { - return { - user: locals.user, - } -} - export const actions: Actions = { login: async (event) => { const data = await event.request.formData() diff --git a/src/routes/(main)/register/+page.server.ts b/src/routes/(main)/register/+page.server.ts index 5f5b626..4d1568a 100644 --- a/src/routes/(main)/register/+page.server.ts +++ b/src/routes/(main)/register/+page.server.ts @@ -1,12 +1,6 @@ import { redirect } from "@sveltejs/kit" import type { Actions, PageServerLoad } from "./$types" -export const load: PageServerLoad = async ({ locals }) => { - return { - user: locals.user, - } -} - export const actions: Actions = { register: async (event) => { const data = await event.request.formData(); diff --git a/src/routes/(main)/settings/+page.server.ts b/src/routes/(main)/settings/+page.server.ts index 7127e0a..5bb072b 100644 --- a/src/routes/(main)/settings/+page.server.ts +++ b/src/routes/(main)/settings/+page.server.ts @@ -2,10 +2,9 @@ import { redirect } from "@sveltejs/kit" import type { Actions, PageServerLoad } from "./$types" import { error } from "@sveltejs/kit" -export const load: PageServerLoad = async ({ locals }) => { - return { - user: locals.user, - } +export const load: PageServerLoad = async ({ cookies }) => { + const user = await authenticateUser(cookies) + return {user} } export const actions: Actions = {