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) <noreply@anthropic.com>
This commit is contained in:
vegard 2026-03-19 03:33:29 +00:00
parent 8d914ed38f
commit 6411347aec

View file

@ -6,12 +6,21 @@ import { sequence } from '@sveltejs/kit/hooks';
const authorizationHandle: Handle = async ({ event, resolve }) => { const authorizationHandle: Handle = async ({ event, resolve }) => {
const path = event.url.pathname; const path = event.url.pathname;
// Allow auth-related routes and landing page through without session check // Allow auth-related routes and signin through without session check
if (path.startsWith('/auth/') || path === '/signin' || path === '/') { if (path.startsWith('/auth/') || path === '/signin') {
return resolve(event); return resolve(event);
} }
const session = await event.locals.auth(); 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) { if (!session?.user) {
throw redirect(303, '/signin'); throw redirect(303, '/signin');
} }