feat: капча Google/Cloudflare, блокировка Яндекс SmartCaptcha

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
shop
2026-05-17 14:41:45 +03:00
parent f9f0446c12
commit 9025677fd8
11 changed files with 251 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
const {
getCaptchaConfig,
YANDEX_BLOCKED_MSG,
isYandexCaptchaAttempt,
} = require('../services/captcha');
function loadCaptchaLocals(req, res, next) {
res.locals.captcha = getCaptchaConfig();
res.locals.yandexCaptchaBlockedMsg = YANDEX_BLOCKED_MSG;
next();
}
/** Блокировка попыток отправить Яндекс-капчу */
function rejectYandexCaptcha(req, res, next) {
if (req.method === 'POST' && isYandexCaptchaAttempt(req)) {
return res.status(403).render('error', {
title: 'Доступ запрещён',
message: YANDEX_BLOCKED_MSG,
code: 403,
});
}
next();
}
module.exports = { loadCaptchaLocals, rejectYandexCaptcha };