public home page with community activity overview

This commit is contained in:
Vincent van der Wal
2026-07-22 11:19:09 +02:00
parent b17f56b194
commit addef8b78e
11 changed files with 198 additions and 93 deletions
+7 -3
View File
@@ -1,17 +1,21 @@
import { error, redirect, type Handle } from '@sveltejs/kit';
import { validateSession } from '$lib/server/auth';
const PUBLIC_PATHS = new Set(['/login', '/signup']);
const AUTH_PATHS = new Set(['/login', '/signup']);
function isPublic(path: string): boolean {
return path === '/' || AUTH_PATHS.has(path) || /^\/activities\/\d+$/.test(path);
}
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 (!event.locals.user && !isPublic(path)) {
if (path.startsWith('/api/')) error(401, 'Not signed in');
redirect(303, '/login');
}
if (event.locals.user && PUBLIC_PATHS.has(path)) {
if (event.locals.user && AUTH_PATHS.has(path)) {
redirect(303, '/');
}