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 username = data.get("username") as string | "";
|
||||||
const password = data.get("password") as string | "";
|
const password = data.get("password") as string | "";
|
||||||
|
|
||||||
if(username === "") {
|
if(username === "") error = "username is required";
|
||||||
error = "username is required";
|
if(password === "") error = "password is required";
|
||||||
Astro.redirect("/login");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(password === "") {
|
|
||||||
error = "password is required";
|
|
||||||
Astro.redirect("/login");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if(error === "") {
|
||||||
const userDB = await getUserByNickOrEmail(username as string);
|
const userDB = await getUserByNickOrEmail(username as string);
|
||||||
|
|
||||||
if(userDB !== null && await verify(userDB.password, password 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");
|
return Astro.redirect("/game");
|
||||||
} else {
|
} else error = "invalid username or password";
|
||||||
error = "invalid username or password";
|
|
||||||
return Astro.redirect("/login");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
---
|
---
|
||||||
|
|
Loading…
Reference in New Issue