main.js: extract captcha reset

This commit is contained in:
Zankaria 2024-08-04 15:07:03 +02:00
parent 1eaa0f7631
commit 30d0b3bfe4

View file

@ -259,17 +259,15 @@ function onCaptchaLoadTurnstile(action) {
action: action, action: action,
}); });
if (widgetId === undefined) { if (widgetId === undefined) {
console.error('Could not render Turnstile captcha!'); return null;
return undefined;
} }
document.addEventListener('post', function(e) {
// User posted! Reset the captcha.
turnstile.reset(widgetId);
});
return widgetId; return widgetId;
}, },
remove: function(widgetId) { remove: function(widgetId) {
turnstile.remove(widgetId); turnstile.remove(widgetId);
},
reset: function(widgetId) {
turnstile.reset(widgetId);
} }
}; };
@ -288,7 +286,6 @@ function onCaptchaLoad(renderer) {
}); });
} }
{% if config.dynamic_captcha %}
function isDynamicCaptchaEnabled() { function isDynamicCaptchaEnabled() {
let cookie = getCookie('captcha-required'); let cookie = getCookie('captcha-required');
return cookie === '1'; return cookie === '1';