From 493746b14c1251a45b061d2e3edd9160c929d2b9 Mon Sep 17 00:00:00 2001 From: benj Date: Fri, 10 Apr 2026 11:13:34 +0800 Subject: a basic ui and landing web interface for tidyindex.com --- web/ui/src/hooks.server.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 web/ui/src/hooks.server.ts (limited to 'web/ui/src/hooks.server.ts') diff --git a/web/ui/src/hooks.server.ts b/web/ui/src/hooks.server.ts new file mode 100644 index 0000000..1204a94 --- /dev/null +++ b/web/ui/src/hooks.server.ts @@ -0,0 +1,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); +}; -- cgit v1.2.3