For some reason first value was always undefined.
This commit is contained in:
parent
75f6b0f982
commit
ec187225be
@ -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.");
|
Loading…
Reference in New Issue
Block a user