diff --git a/web/src/lib/constants.ts b/web/src/lib/constants.ts index 859831f40b..9af3d5814f 100644 --- a/web/src/lib/constants.ts +++ b/web/src/lib/constants.ts @@ -10,5 +10,7 @@ export enum AppRoute { ALBUMS = '/albums', FAVORITES = '/favorites', PHOTOS = '/photos', - SHARING = '/sharing' + SHARING = '/sharing', + + AUTH_LOGIN = '/auth/login' } diff --git a/web/src/routes/admin/+layout.svelte b/web/src/routes/admin/+layout.svelte index 59c1ef18af..217f901f01 100644 --- a/web/src/routes/admin/+layout.svelte +++ b/web/src/routes/admin/+layout.svelte @@ -1,5 +1,11 @@ - +
@@ -34,25 +45,25 @@ goto(AppRoute.ADMIN_USER_MANAGEMENT)} /> goto(AppRoute.ADMIN_JOBS)} /> goto(AppRoute.ADMIN_SETTINGS)} /> goto(AppRoute.ADMIN_STATS)} />
@@ -63,7 +74,7 @@

- {getPageTitle($page.route.id)} + {getPageTitle(data.routeId)}


diff --git a/web/src/routes/admin/+layout.ts b/web/src/routes/admin/+layout.ts new file mode 100644 index 0000000000..e2128861b9 --- /dev/null +++ b/web/src/routes/admin/+layout.ts @@ -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;