import { redirect } from '@sveltejs/kit'; import { user } from '#lib/auth/store.svelte.js'; import type { LayoutLoad } from './$types'; // Hard route gate: runs before the layout (and any child page) renders. // Auth is guaranteed bootstrapped by the root +layout.ts, so user.value is // either a settled User object or null. export const load: LayoutLoad = () => { if (!user.value || !user.value.is_admin) { throw redirect(302, '/'); } return {}; };