diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2022-11-14 05:05:40 +0100 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2022-11-14 05:05:40 +0100 |
| commit | df5402f3e762715aa88ce88898b0995dac1648e0 (patch) | |
| tree | 5867540e46577d3d639609f1d759007e02881963 /code/app/src/routes/(main) | |
| parent | 04a2b73805fc1213df42ef9af4cdcf27ff7c86db (diff) | |
| download | greatoffice-df5402f3e762715aa88ce88898b0995dac1648e0.tar.xz greatoffice-df5402f3e762715aa88ce88898b0995dac1648e0.zip | |
fix: Align with new api to get routeId
Diffstat (limited to 'code/app/src/routes/(main)')
| -rw-r--r-- | code/app/src/routes/(main)/+layout.server.ts | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/code/app/src/routes/(main)/+layout.server.ts b/code/app/src/routes/(main)/+layout.server.ts index 0277a2c..5a3c1a2 100644 --- a/code/app/src/routes/(main)/+layout.server.ts +++ b/code/app/src/routes/(main)/+layout.server.ts @@ -3,8 +3,9 @@ import { log_error } from "$lib/logger"; import { error, redirect } from "@sveltejs/kit"; import type { LayoutServerLoad } from "./$types"; -export const load: LayoutServerLoad = async ({ routeId, cookies, locals }) => { - const isPublicRoute = (routeId?.startsWith("(main)/(public)") || routeId === "(main)") ?? true; +export const load: LayoutServerLoad = async ({ route, cookies, locals }) => { + const isBaseRoute = route.id === "/(main)"; + const isPublicRoute = (route.id?.startsWith("/(main)/(public)") || isBaseRoute) ?? true; const sessionIsValid = (await fetch(api_base("_/valid-session"), { headers: { Cookie: CookieNames.session + "=" + cookies.get(CookieNames.session) @@ -19,12 +20,12 @@ export const load: LayoutServerLoad = async ({ routeId, cookies, locals }) => { console.log("Base Layout loaded", { sessionIsValid, isPublicRoute, - routeId + routeId: route.id }); if (sessionIsValid && isPublicRoute) { throw redirect(302, "/home"); - } else if (routeId === "(main)" || !sessionIsValid && !isPublicRoute) { + } else if (isBaseRoute || !sessionIsValid && !isPublicRoute) { throw redirect(302, "/sign-in"); } |
