feat: капча Google/Cloudflare, блокировка Яндекс SmartCaptcha
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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 };
|
||||
Reference in New Issue
Block a user