This commit is contained in:
@ -21,7 +21,6 @@ export default defineAstroI18nConfig({
|
||||
statistiken: "stats",
|
||||
ankuendigungen: "announcements",
|
||||
datenschutzerklaerung: "privacy-policy",
|
||||
"passwort-zuruecksetzen": "reset-password",
|
||||
"passwort-setzen": "set-password",
|
||||
},
|
||||
},
|
||||
|
||||
@ -1,81 +0,0 @@
|
||||
<!--
|
||||
- This file is a part of the SteamWar software.
|
||||
-
|
||||
- Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
-
|
||||
- This program is free software: you can redistribute it and/or modify
|
||||
- it under the terms of the GNU Affero General Public License as published by
|
||||
- the Free Software Foundation, either version 3 of the License, or
|
||||
- (at your option) any later version.
|
||||
-
|
||||
- This program is distributed in the hope that it will be useful,
|
||||
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
- GNU Affero General Public License for more details.
|
||||
-
|
||||
- You should have received a copy of the GNU Affero General Public License
|
||||
- along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
|
||||
<script lang="ts">
|
||||
import { preventDefault } from 'svelte/legacy';
|
||||
|
||||
import {l} from "@utils/util.ts";
|
||||
import {t} from "astro-i18n";
|
||||
import {get} from "svelte/store";
|
||||
import {navigate} from "astro:transitions/client";
|
||||
|
||||
let username: string = $state("");
|
||||
let pw: string = $state("");
|
||||
let pw2: string = $state("");
|
||||
|
||||
let error: string = $state("");
|
||||
|
||||
async function resetPW() {
|
||||
let {authV2Repo} = await import("./repo/authv2.ts");
|
||||
if (username === "" || pw === "" || pw2 === "" || pw !== pw2) {
|
||||
pw = "";
|
||||
pw2 = "";
|
||||
error = t("login.error");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const token = decodeURI(new URLSearchParams(window.location.search).get("token") ?? "");
|
||||
await get(authV2Repo).resetPassword(username, pw, token);
|
||||
|
||||
await navigate(l("/login"));
|
||||
} catch (e: any) {
|
||||
pw = "";
|
||||
error = t("login.error");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<form class="bg-gray-100 dark:bg-neutral-900 p-12 rounded-2xl shadow-2xl border-2 border-gray-600 flex flex-col" onsubmit={preventDefault(resetPW)}>
|
||||
<h1 class="text-4xl text-white text-center">{t("login.title")}</h1>
|
||||
<div class="ml-2 flex flex-col">
|
||||
<label for="username">{t("login.label.username")}</label>
|
||||
<input type="text" id="username" name="username" placeholder={t("login.placeholder.username")} bind:value={username} />
|
||||
<label for="password">{t("login.label.password")}</label>
|
||||
<input type="password" id="password" name="password" placeholder={t("login.placeholder.password")} bind:value={pw} />
|
||||
<label for="password-repeat">{t("login.label.repeat")}</label>
|
||||
<input type="password" id="password-repeat" name="password-repeat" placeholder={t("login.placeholder.password")} bind:value={pw2} />
|
||||
</div>
|
||||
|
||||
{#if error}
|
||||
<p class="mt-2 text-red-500">{error}</p>
|
||||
{/if}
|
||||
<button class="btn mt-4 !mx-0 justify-center" type="submit" onclick={preventDefault(resetPW)}>{t("login.submit")}</button>
|
||||
</form>
|
||||
|
||||
<style lang="postcss">
|
||||
input {
|
||||
@apply border-2 rounded-md p-2 shadow-2xl w-80 dark:bg-neutral-800 focus:outline-none focus:ring-2 focus:ring-neutral-500 focus:border-transparent text-black;
|
||||
}
|
||||
|
||||
label {
|
||||
@apply text-neutral-300;
|
||||
}
|
||||
</style>
|
||||
@ -51,7 +51,7 @@ export class AuthV2Repo {
|
||||
}
|
||||
|
||||
try {
|
||||
const login = await this.request("/auth/state", {
|
||||
const login = await this.request("/auth", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
name,
|
||||
@ -68,22 +68,12 @@ export class AuthV2Repo {
|
||||
}
|
||||
}
|
||||
|
||||
async resetPassword(name: string, password: string, token: string) {
|
||||
return await this.requestWithToken(token, "/auth/register", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
name,
|
||||
password,
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
async logout() {
|
||||
if (this.accessToken === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
await this.request("/auth/state", {
|
||||
await this.request("/auth", {
|
||||
method: "DELETE",
|
||||
});
|
||||
|
||||
@ -142,7 +132,7 @@ export class AuthV2Repo {
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await this.requestWithToken(this.refreshToken!, "/auth/state", {
|
||||
const response = await this.requestWithToken(this.refreshToken!, "/auth", {
|
||||
method: "PUT",
|
||||
}).then(value => value.json()).then(value => AuthTokenSchema.parse(value));
|
||||
|
||||
|
||||
@ -1,16 +0,0 @@
|
||||
---
|
||||
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>
|
||||
Reference in New Issue
Block a user