Fix error messages not showing on login form

This commit is contained in:
Aelita4 2024-11-03 23:33:12 +01:00
parent 1bbc55563d
commit a9e9c5b080
Signed by: Aelita4
GPG Key ID: E44490C2025906C1
1 changed files with 49 additions and 57 deletions

View File

@ -16,16 +16,10 @@ if(Astro.request.method === "POST") {
const username = data.get("username") as string | "";
const password = data.get("password") as string | "";
if(username === "") {
error = "username is required";
Astro.redirect("/login");
}
if(password === "") {
error = "password is required";
Astro.redirect("/login");
}
if(username === "") error = "username is required";
if(password === "") error = "password is required";
if(error === "") {
const userDB = await getUserByNickOrEmail(username as string);
if(userDB !== null && await verify(userDB.password, password as string)) {
@ -79,9 +73,7 @@ if(Astro.request.method === "POST") {
});
return Astro.redirect("/game");
} else {
error = "invalid username or password";
return Astro.redirect("/login");
} else error = "invalid username or password";
}
}
---