From c3b3f6763ebc2ebeb6380a16f86b3125b4cfe9ea Mon Sep 17 00:00:00 2001 From: Anatoly Kopyl Date: Tue, 23 Mar 2021 20:37:14 +0300 Subject: [PATCH] Status codes --- server.js | 6 +++--- verify-captcha.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/server.js b/server.js index a117876..f382bf8 100644 --- a/server.js +++ b/server.js @@ -29,16 +29,16 @@ client.connect() app.get('/', (req, res) => { if (req.session.loggedIn) { - res.sendFile(__dirname+'/public/personal.html') + res.status(200).sendFile(__dirname+'/public/personal.html') } else { - res.sendFile(__dirname+'/public/auth.html') + res.status(200).sendFile(__dirname+'/public/auth.html') } }) app.get('/get-users', async (_, res) => { try { const users = await client.db('reg_example').collection('users').find().toArray() - res.send(users) + res.status(200).send(users) } catch (e) { console.log("Error: " + e) res.status(500).send() diff --git a/verify-captcha.js b/verify-captcha.js index 3e123da..6307492 100644 --- a/verify-captcha.js +++ b/verify-captcha.js @@ -3,14 +3,14 @@ const axios = require('axios') module.exports = { verifyCaptcha: function (req, res, cb) { if (!req.body['g-recaptcha-response']) { - return res.status(401).send("Invalid captcha") + return res.status(400).send("No captcha") } const URL = "https://www.google.com/recaptcha/api/siteverify?secret=" + process.env.SECRET_KEY + "&response=" + req.body['g-recaptcha-response'] + "&remoteip=" + req.socket.remoteAddress axios.get(URL).then(function (response) { if (response.data.success !== undefined && !response.data.success) { - return res.status(401).send("Invalid captcha") + return res.status(429).send("Invalid captcha") } cb()