Initial commit of Vox English challenge system

This commit is contained in:
chaos
2026-03-17 00:05:46 +08:00
commit 8a055daf5e
41 changed files with 4790 additions and 0 deletions

20
src/hooks.server.ts Normal file
View File

@@ -0,0 +1,20 @@
import { redirect, type Handle } from '@sveltejs/kit';
import { getSession } from '$lib/server/auth';
export const handle: Handle = async ({ event, resolve }) => {
const session = getSession(event.cookies);
event.locals.user = session;
const path = event.url.pathname;
// Public routes that don't need auth
const publicRoutes = ['/login', '/register', '/api/auth'];
const isPublicRoute = publicRoutes.some(route => path.startsWith(route));
if (!event.locals.user && !isPublicRoute && path !== '/') {
throw redirect(303, '/login');
}
const response = await resolve(event);
return response;
};