add user accounts and OSM peak catalog with zoom-based notability

This commit is contained in:
Vincent van der Wal
2026-07-22 11:10:59 +02:00
parent 196f30521c
commit b17f56b194
26 changed files with 1019 additions and 191 deletions
+19
View File
@@ -0,0 +1,19 @@
import { error, redirect, type Handle } from '@sveltejs/kit';
import { validateSession } from '$lib/server/auth';
const PUBLIC_PATHS = new Set(['/login', '/signup']);
export const handle: Handle = async ({ event, resolve }) => {
event.locals.user = validateSession(event.cookies.get('session'));
const path = event.url.pathname;
if (!event.locals.user && !PUBLIC_PATHS.has(path)) {
if (path.startsWith('/api/')) error(401, 'Not signed in');
redirect(303, '/login');
}
if (event.locals.user && PUBLIC_PATHS.has(path)) {
redirect(303, '/');
}
return resolve(event);
};