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