From 75f6123aabfa89bb8b3bf7ebc1ac55f1dedb2ca7 Mon Sep 17 00:00:00 2001 From: Owen Rummage Date: Fri, 24 Jan 2025 20:30:55 -0600 Subject: [PATCH] fix readme, again --- README.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b44c0d9..5ec395d 100644 --- a/README.md +++ b/README.md @@ -126,12 +126,12 @@ export const handle: Handle = async ({ event, resolve }) => { import { getUser } from '$lib/auth'; import type { LayoutServerLoad } from './$types'; -export const load: LayoutServerLoad = async ({ locals, cookies }) => { +export const load: LayoutServerLoad = async ({ locals }) => { // Access the user data set in hooks.server.ts - const data = await getUser(cookies.get('session_id')); + const user = locals.user; return { - user: data.user + user }; }; @@ -142,7 +142,17 @@ With these three items you can auto-autnticate every single page. Please keep in ```ts // src/routes/+layout.server.ts +import { getUser } from '$lib/auth'; +import type { LayoutServerLoad } from './$types'; +export const load: LayoutServerLoad = async ({ locals, cookies }) => { + // Access the user data set in hooks.server.ts + const data = await getUser(cookies.get('session_id')); + + return { + user: data.user + }; +}; ``` ---