blockbypass captcha auto load and add word answer to incorrect messages

merge-requests/208/head
fatchan 4 years ago
parent 3170de1743
commit ce1fb88863
  1. 12
      gulp/res/js/captcha.js
  2. 8
      helpers/captcha/captchaverify.js
  3. 2
      models/forms/makepost.js

@ -31,13 +31,13 @@ window.addEventListener('DOMContentLoaded', (event) => {
};
const loadCaptcha = function(e) {
const captchaDiv = this.previousSibling;
const field = e.target;
const captchaDiv = field.previousSibling;
const captchaImg = document.createElement('img');
const refreshDiv = document.createElement('div');
refreshDiv.classList.add('captcharefresh', 'noselect');
refreshDiv.addEventListener('click', refreshCaptchas, true);
refreshDiv.textContent = '↻';
const field = this;
field.placeholder = 'loading';
captchaImg.src = '/captcha';
captchaImg.onload = function() {
@ -49,8 +49,12 @@ window.addEventListener('DOMContentLoaded', (event) => {
};
for (let i = 0; i < captchaFields.length; i++) {
captchaFields[i].placeholder = 'focus to load captcha';
captchaFields[i].addEventListener('focus', loadCaptcha, { once: true });
const field = captchaFields[i];
if (field.form.action.endsWith('/forms/blockbypass')) {
return loadCaptcha({target: field })
}
field.placeholder = 'focus to load captcha';
field.addEventListener('focus', loadCaptcha, { once: true });
}
});

@ -27,12 +27,12 @@ module.exports = async (req, res, next) => {
if (isBypass) {
return res.status(403).render('bypass', {
'minimal': req.body.minimal,
'message': 'Incorrect captcha',
'message': 'Incorrect captcha answer',
});
}
return dynamicResponse(req, res, 403, 'message', {
'title': 'Forbidden',
'message': 'Incorrect captcha',
'message': 'Incorrect captcha answer',
'redirect': req.headers.referer,
});
}
@ -69,12 +69,12 @@ module.exports = async (req, res, next) => {
if (isBypass) {
return res.status(403).render('bypass', {
'minimal': req.body.minimal,
'message': 'Incorrect captcha',
'message': 'Incorrect captcha answer',
});
}
return dynamicResponse(req, res, 403, 'message', {
'title': 'Forbidden',
'message': 'Incorrect captcha',
'message': 'Incorrect captcha answer',
'redirect': req.headers.referer,
});
}

@ -403,7 +403,7 @@ module.exports = async (req, res, next) => {
}).skip(replyLimit).toArray();
if (cyclicOverflowPosts.length > 0) {
await deletePosts(cyclicOverflowPosts, req.params.board);
const fileCount = cyclicOverflowPosts.reduce((post, acc) => {
const fileCount = cyclicOverflowPosts.reduce((acc, post) => {
return acc + (post.files ? post.files.length : 0);
}, 0);
//reduce amount counted in post by number of posts deleted

Loading…
Cancel
Save