forked from leftypol/leftypol
main.js: fix reset wiping the captcha token from the form before it was sent
This commit is contained in:
parent
b83be67b55
commit
057addafa8
1 changed files with 3 additions and 2 deletions
|
@ -282,7 +282,7 @@ function onCaptchaLoad(renderer) {
|
|||
if (widgetId === null) {
|
||||
console.error('Could not render captcha!');
|
||||
}
|
||||
document.addEventListener('post', function(e) {
|
||||
document.addEventListener('afterdopost', function(e) {
|
||||
// User posted! Reset the captcha.
|
||||
renderer.reset(widgetId);
|
||||
});
|
||||
|
@ -352,7 +352,8 @@ function doPost(form) {
|
|||
saved[document.location] = form.elements['body'].value;
|
||||
sessionStorage.body = JSON.stringify(saved);
|
||||
|
||||
document.dispatchEvent(new Event('post'));
|
||||
// Needs to be delayed by at least 1 frame, otherwise it may reset the form (read captcha) fields before they're sent.
|
||||
setTimeout(() => document.dispatchEvent(new Event('afterdopost')));
|
||||
return form.elements['body'].value != "" || (form.elements['file'] && form.elements['file'].value != "") || (form.elements.file_url && form.elements['file_url'].value != "");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue