For some reason first value was always undefined.

This commit is contained in:
Alexander Andreev 2022-06-25 04:33:40 +04:00
parent 75f6b0f982
commit ec187225be
Signed by: Arav
GPG Key ID: 0388CC8FAA51063F
1 changed files with 5 additions and 11 deletions

View File

@ -61,7 +61,7 @@ async function solveCaptcha(id, answer) {
body.append('answer', answer);
let result = fetch(`http://127.0.0.1:19322/${id}`, { method: "POST", body: body } );
return await result.then(r => {
return r.status == 200, r.status;
return r.status == 200;
});
} catch {
return false;
@ -146,14 +146,10 @@ function setRoutes() {
post.hide_website = post.hide_website !== undefined;
try {
let check, status = await solveCaptcha(post.captcha_id, post.captcha_answer);
if (!check) {
if (status == 404) {
throw "CAPTCHA expired";
} else {
throw "wrong CAPTCHA";
}
}
let check = await solveCaptcha(post.captcha_id, post.captcha_answer);
console.log(check);
if (!check)
throw "CAPTCHA is wrong or expired";
if (await guestbook.addPost(post))
ctx.redirect("/guestbook");
@ -200,5 +196,3 @@ app
})
.use(setRoutes().routes())
.listen(config.port, config.host);
console.log("Arav's dwelling / Homepage is up.");