Add admin panel

This commit is contained in:
Esa Kataja
2024-12-02 15:26:24 +02:00
parent fe14660601
commit aed5c675d3
3 changed files with 310 additions and 0 deletions
+11
View File
@@ -13,6 +13,17 @@ export const handle: Handle = async ({ event, resolve }) => {
}
if (event.url.pathname.startsWith('/admin')) {
const current_user = await authenticateUser(event);
if (!current_user) {
throw redirect(302, '/login');
}
if (!current_user.is_admin) {
throw redirect(302, '/');
}
event.locals.user = current_user;
}
const response = await resolve(event);
return response;
};