workspace.synops.no: redirect til login/workspace, aldri vis landingsside

Host-basert logikk i hooks: workspace.* sender uautentiserte til
login og autentiserte til /workspace. synops.no viser landingsside.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
vegard 2026-03-19 03:47:02 +00:00
parent 32c3dfc1b0
commit be6aa2b1bc

View file

@ -13,8 +13,17 @@ const authorizationHandle: Handle = async ({ event, resolve }) => {
const session = await event.locals.auth(); const session = await event.locals.auth();
// Landing page: show for unauthenticated, redirect to workspace for authenticated // Landing page: only on synops.no (not workspace.synops.no)
if (path === '/') { if (path === '/') {
const host = event.url.hostname;
if (host.startsWith('workspace.')) {
// workspace.synops.no: uautentisert → login, autentisert → workspace
if (!session?.user) {
throw redirect(303, '/auth/signin');
}
throw redirect(303, '/workspace');
}
// synops.no: vis landingsside for alle
if (session?.user) { if (session?.user) {
throw redirect(303, '/workspace'); throw redirect(303, '/workspace');
} }