Fix error messages not showing on login form
This commit is contained in:
parent
1bbc55563d
commit
a9e9c5b080
|
@ -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";
|
||||
}
|
||||
}
|
||||
---
|
||||
|
|
Loading…
Reference in New Issue