client/src/routes/+layout.server.ts (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import { redirect } from '@sveltejs/kit'; import type { LayoutServerLoad } from './$types'; export const load: LayoutServerLoad = async (event) => { const session = await event.locals.auth(); if (!session?.user?.name) { if (event.url.pathname !== '/login') { throw redirect(303, `/login`); } } return { session }; }; |