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 };