diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2022-10-05 14:45:21 +0200 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2022-10-05 14:45:21 +0200 |
| commit | b7e39b59fd0fc7b5610ebff29035bf622079e0d8 (patch) | |
| tree | 64be84ebbdac9f7ceced983390c53b10d575af5c /apps/kit/src/routes/(main)/+layout.server.ts | |
| parent | 2001c035fbb417ab0a3d42cfb04d17420bde4086 (diff) | |
| download | greatoffice-b7e39b59fd0fc7b5610ebff29035bf622079e0d8.tar.xz greatoffice-b7e39b59fd0fc7b5610ebff29035bf622079e0d8.zip | |
refactor: Change file structure
Diffstat (limited to 'apps/kit/src/routes/(main)/+layout.server.ts')
| -rw-r--r-- | apps/kit/src/routes/(main)/+layout.server.ts | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/apps/kit/src/routes/(main)/+layout.server.ts b/apps/kit/src/routes/(main)/+layout.server.ts deleted file mode 100644 index d2eb2eb..0000000 --- a/apps/kit/src/routes/(main)/+layout.server.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { api_base, CookieNames } from "$lib/configuration"; -import { logError } 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; - - let sessionIsValid = (await fetch(api_base("_/valid-session"), { - headers: { - Cookie: CookieNames.session + "=" + cookies.get(CookieNames.session) - } - }).catch((e) => { - logError(e); - throw error(503, { - message: "We are experiencing a service distruption! Have patience while we resolve the issue." - }) - })).ok; - - console.log("Base Layout loaded", { - sessionIsValid, - isPublicRoute, - routeId - }); - - if (sessionIsValid && isPublicRoute) { - throw redirect(302, "/home"); - } else if (!sessionIsValid && !isPublicRoute) { - throw redirect(302, "/sign-in"); - } - return { - locale: locals.locale - } -};
\ No newline at end of file |
