Status codes

This commit is contained in:
2021-03-23 20:37:14 +03:00
parent 3368b9f0d9
commit c3b3f6763e
2 changed files with 5 additions and 5 deletions

View File

@@ -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()