最新版本的recaptcha不再需要挑战字段,angular-recaptcha指令与这些更改保持同步,但没有任何节点重新访问库在没有挑战字段的情况下工作。
如何在没有质询字段的情况下验证节点中的重新接收?
答案 0 :(得分:0)
function verifyRecaptcha(key, callback) {
https.get("https://www.google.com/recaptcha/api/siteverify?secret=" + recaptcha_vars.privateKey + "&response=" + key, function(res) {
var data = "";
res.on('data', function (chunk) {
data += chunk.toString();
});
res.on('end', function() {
try {
var parsedData = JSON.parse(data);
console.log(parsedData);
callback(parsedData.success);
} catch (e) {
callback(false);
}
});
});
}
exports.captcha = function(req, res) {
verifyRecaptcha(req.body.response, function(success) {
if (success) {
res.json({ success: true });
// TODO: do registration using params in req.body
} else {
res.json({ success: success, error: "Captcha failed"});
// TODO: take them back to the previous page
// and for the love of everyone, restore their inputs
}
});
};