From ec187225beed21e1c7ca0dee8ce717207493d283 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Sat, 25 Jun 2022 04:33:40 +0400 Subject: [PATCH] For some reason first value was always undefined. --- homepage/index.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/homepage/index.js b/homepage/index.js index d974e93..8d0ec23 100644 --- a/homepage/index.js +++ b/homepage/index.js @@ -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."); \ No newline at end of file