blob: 1204a94e100a819aa870888a4015b5b4558a4bf1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
import { redirect, type Handle } from '@sveltejs/kit';
import { getAccountFromCookies } from '$lib/server/auth';
export const handle: Handle = async ({ event, resolve }) => {
event.locals.account = getAccountFromCookies(event.cookies);
const path = event.url.pathname;
// /dashboard/* requires a session. Bounce to the entry page if missing.
if (path.startsWith('/dashboard') && !event.locals.account) {
throw redirect(303, '/');
}
return resolve(event);
};
|