Compare commits

..

2 Commits

Author SHA1 Message Date
38743398e0 make session cookie name a variable
All checks were successful
delpoy / build-and-deploy (push) Successful in 34s
2023-08-29 14:48:42 +02:00
f2c620e37b redirect to admin login when trying to access any admin page without valid cookies 2023-08-29 14:44:20 +02:00

View File

@ -4,11 +4,10 @@ import { getSession } from '$lib/server/session';
import { redirect } from '@sveltejs/kit';
import { env } from '$env/dynamic/public';
export const load: LayoutServerLoad = async ({ route, cookies }) => {
export const load: LayoutServerLoad = async ({ cookies }) => {
const session = getSession(cookies);
if (session == null && route.id != '/admin/login')
throw redirect(302, `${env.PUBLIC_BASE_PATH}/admin/login`);
if (session == null) throw redirect(302, `${env.PUBLIC_BASE_PATH}/admin/login`);
return {
userCount: session?.permissions.userRead() ? await User.count() : null,