diff --git a/src/pages/dashboard.astro b/src/pages/dashboard.astro index 9c30cf4..1315fcb 100644 --- a/src/pages/dashboard.astro +++ b/src/pages/dashboard.astro @@ -9,11 +9,13 @@ import {t} from "astro-i18n"; import {l} from "../util/util"; import {navigate} from "astro:transitions/client"; - if (window.location.href.endsWith("/dashboard") || window.location.href.endsWith("/dashboard/")) { - if ((localStorage.getItem("sw-session") ?? "") === "") { - navigate(l("/login"), {}); + document.addEventListener("astro:page-load", () => { + if (window.location.href.endsWith("/dashboard") || window.location.href.endsWith("/dashboard/")) { + if ((localStorage.getItem("sw-session") ?? "") === "") { + navigate(l("/login"), {}); + } } - } + }); \ No newline at end of file diff --git a/src/pages/login.astro b/src/pages/login.astro index a634026..d654e5d 100644 --- a/src/pages/login.astro +++ b/src/pages/login.astro @@ -11,11 +11,13 @@ import localBau from "@images/2023-10-08_20.43.43.png"; import {l} from "../util/util"; import {navigate} from "astro:transitions/client"; - if (window.location.href.endsWith("/login") || window.location.href.endsWith("/login/")) { - if ((localStorage.getItem("sw-session") ?? "") !== "") { - navigate(l("/dashboard")); + document.addEventListener("astro:page-load", () => { + if (window.location.href.endsWith("/login") || window.location.href.endsWith("/login/")) { + if ((localStorage.getItem("sw-session") ?? "") !== "") { + navigate(l("/dashboard"), {history: "replace"}); + } } - } + }); Bau