aboutsummaryrefslogtreecommitdiffstats
path: root/code/app/src/routes
diff options
context:
space:
mode:
authorivarlovlie <git@ivarlovlie.no>2022-10-09 18:42:33 +0200
committerivarlovlie <git@ivarlovlie.no>2022-10-09 18:42:33 +0200
commit7bbd3891a76d3a6da20a4aa3888e6da87e41aa6d (patch)
treec3602e6b8c3f2f79fb9c28465963365aaf49d8c4 /code/app/src/routes
parentb2b76d0552ecf0c57a4d39fb0a1caa9b4c10bee9 (diff)
downloadgreatoffice-7bbd3891a76d3a6da20a4aa3888e6da87e41aa6d.tar.xz
greatoffice-7bbd3891a76d3a6da20a4aa3888e6da87e41aa6d.zip
refactor/fix: Small refactors/fixes, update imports
Diffstat (limited to 'code/app/src/routes')
-rw-r--r--code/app/src/routes/(main)/+layout.server.ts10
-rw-r--r--code/app/src/routes/(main)/+layout.ts4
2 files changed, 5 insertions, 9 deletions
diff --git a/code/app/src/routes/(main)/+layout.server.ts b/code/app/src/routes/(main)/+layout.server.ts
index d2eb2eb..0277a2c 100644
--- a/code/app/src/routes/(main)/+layout.server.ts
+++ b/code/app/src/routes/(main)/+layout.server.ts
@@ -1,17 +1,16 @@
import { api_base, CookieNames } from "$lib/configuration";
-import { logError } from "$lib/logger";
+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;
-
- let sessionIsValid = (await fetch(api_base("_/valid-session"), {
+ const sessionIsValid = (await fetch(api_base("_/valid-session"), {
headers: {
Cookie: CookieNames.session + "=" + cookies.get(CookieNames.session)
}
}).catch((e) => {
- logError(e);
+ log_error(e);
throw error(503, {
message: "We are experiencing a service distruption! Have patience while we resolve the issue."
})
@@ -25,9 +24,10 @@ export const load: LayoutServerLoad = async ({ routeId, cookies, locals }) => {
if (sessionIsValid && isPublicRoute) {
throw redirect(302, "/home");
- } else if (!sessionIsValid && !isPublicRoute) {
+ } else if (routeId === "(main)" || !sessionIsValid && !isPublicRoute) {
throw redirect(302, "/sign-in");
}
+
return {
locale: locals.locale
}
diff --git a/code/app/src/routes/(main)/+layout.ts b/code/app/src/routes/(main)/+layout.ts
index 5d0e005..491ea1f 100644
--- a/code/app/src/routes/(main)/+layout.ts
+++ b/code/app/src/routes/(main)/+layout.ts
@@ -6,10 +6,6 @@ import { setLocale } from '$lib/i18n/i18n-svelte'
export const load: LayoutLoad<{ locale: Locales }> = async ({ data: { locale } }) => {
// load dictionary into memory
await loadLocaleAsync(locale)
-
- // if you need to output a localized string in a `load` function,
- // you always need to call `setLocale` right before you access the `LL` store
setLocale(locale)
- // pass locale to the "rendering context"
return { locale }
} \ No newline at end of file