fix(web): admin pages layout issue (#1943)

This commit is contained in:
Michel Heusschen
2023-03-05 15:03:51 +01:00
committed by GitHub
parent 1918625be9
commit 6f605d4a35
3 changed files with 35 additions and 8 deletions
+14
View File
@@ -0,0 +1,14 @@
import { AppRoute } from '$lib/constants';
import { redirect } from '@sveltejs/kit';
import type { LayoutLoad } from './$types';
export const load = (async ({ parent, route }) => {
const { user } = await parent();
if (!user) {
throw redirect(302, AppRoute.AUTH_LOGIN);
} else if (!user.isAdmin) {
throw redirect(302, AppRoute.PHOTOS);
}
return { routeId: route.id, user };
}) satisfies LayoutLoad;