Refactor authentication and implement password reset.
All checks were successful
SteamWarCI Build successful

This commit is contained in:
2025-02-17 18:29:17 +01:00
parent 23f35a35c4
commit 75f1a6528b
13 changed files with 360 additions and 95 deletions

View File

@@ -8,9 +8,11 @@ import {t} from "astro-i18n";
<script>
import {l} from "../util/util";
import {navigate} from "astro:transitions/client";
import {get} from "svelte/store";
import {loggedIn} from "../components/repo/authv2";
document.addEventListener("astro:page-load", () => {
if (window.location.href.endsWith("/dashboard") || window.location.href.endsWith("/dashboard/")) {
if ((localStorage.getItem("sw-session") ?? "") === "") {
if (!get(loggedIn)) {
navigate(l("/login"), {});
}
}

View File

@@ -9,10 +9,12 @@ import BackgroundImage from "../components/BackgroundImage.astro";
<script>
import {l} from "../util/util";
import {navigate} from "astro:transitions/client";
import {loggedIn} from "../components/repo/authv2";
import {get} from "svelte/store";
document.addEventListener("astro:page-load", () => {
if (window.location.href.endsWith("/login") || window.location.href.endsWith("/login/")) {
if ((localStorage.getItem("sw-session") ?? "") !== "") {
if (get(loggedIn)) {
navigate(l("/dashboard"), {history: "replace"});
}
}

View File

@@ -0,0 +1,16 @@
---
import {t} from "astro-i18n";
import BackgroundImage from "../components/BackgroundImage.astro";
import ResetPasswordComponent from "../components/ResetPasswordComponent.svelte";
import NavbarLayout from "../layouts/NavbarLayout.astro";
---
<NavbarLayout title={t("login.page")}>
<div class="h-screen w-screen fixed -z-10">
<BackgroundImage />
</div>
<div class="h-screen mx-auto p-8 rounded-b-md pt-40 sm:pt-28 md:pt-14 flex flex-col justify-center items-center
dark:text-white " style="width: min(100vw, 75em);">
<ResetPasswordComponent client:load/>
</div>
</NavbarLayout>