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