refactoring magic strings in layout.server file (guard), including new routes and tests

This commit is contained in:
2025-09-26 11:59:21 +02:00
parent 59abf0880d
commit f43497d69c
4 changed files with 42 additions and 3 deletions

View File

@@ -1,10 +1,12 @@
import { redirect, type ServerLoadEvent } from '@sveltejs/kit';
import type { PageServerLoad } from '../anmeldung/$types';
import { ROUTE_NAMES } from '..';
export const load: PageServerLoad = (event: ServerLoadEvent) => {
if (!event.locals.user && event.url.pathname !== '/anmeldung') throw redirect(303, '/anmeldung');
if (!event.locals.user && event.url.pathname !== ROUTE_NAMES.ANMELDUNG)
throw redirect(303, ROUTE_NAMES.ANMELDUNG);
return {
user: event.locals.user
};
}
};

View File

@@ -17,6 +17,7 @@ export const ROUTE_NAMES = {
: `/view/${vorgangToken}/${tatort}`,
// Anmeldung: actions
ANMELDUNG: '/anmeldung',
ANMELDUNG_LOGIN: '/anmeldung?/login',
ANMELDUNG_LOGOUT: '/anmeldung?/logout'
};