From 6411347aec3aa76a3a2505b8c2600581393c78f6 Mon Sep 17 00:00:00 2001 From: vegard Date: Thu, 19 Mar 2026 03:33:29 +0000 Subject: [PATCH] Redirect innloggede fra / til /workspace Uautentiserte ser landingssiden, innloggede sendes rett til arbeidsflaten. Mottak er tilgjengelig som eget panel. Co-Authored-By: Claude Opus 4.6 (1M context) --- frontend/src/hooks.server.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/frontend/src/hooks.server.ts b/frontend/src/hooks.server.ts index e02d47a..7c6b94c 100644 --- a/frontend/src/hooks.server.ts +++ b/frontend/src/hooks.server.ts @@ -6,12 +6,21 @@ import { sequence } from '@sveltejs/kit/hooks'; const authorizationHandle: Handle = async ({ event, resolve }) => { const path = event.url.pathname; - // Allow auth-related routes and landing page through without session check - if (path.startsWith('/auth/') || path === '/signin' || path === '/') { + // Allow auth-related routes and signin through without session check + if (path.startsWith('/auth/') || path === '/signin') { return resolve(event); } const session = await event.locals.auth(); + + // Landing page: show for unauthenticated, redirect to workspace for authenticated + if (path === '/') { + if (session?.user) { + throw redirect(303, '/workspace'); + } + return resolve(event); + } + if (!session?.user) { throw redirect(303, '/signin'); }