I have implemented a "auto-submit" feature on my site using the "verified" event of the widget but the server is not receiving any input.
On the past I opened a issue (#10) because the hidden input was not created when triggering the "verified" event. This issue has again been introduced.
If I submit the form on the next tick, inside a setTimeout with delay 0, the input is received on the server.
How to reproduce the issue, create a form and add the following altcha widget.
Create a script (I'm using typescript) to initialize altcha.
import "altcha";
document.addEventListener("DOMContentLoaded", (): void => {
const widgets = document.querySelectorAll<HTMLElement>("altcha-widget");
for (let i = 0; i < widgets.length; i++) {
const widget = widgets[i] as any;
if (widget.hasAttribute("data-submit-verified")) {
widget.addEventListener("verified", onWidgetVerified.bind(widget));
}
}
});
function onWidgetVerified(this: HTMLElement): void {
const form = this.closest("form");
if (!form) {
return;
}
// submit at this point does not work
form.submit();
// submit inside setTimeout works
/*setTimeout((): void => {
form.submit();
}, 0);*/
}
Open the html and complete the challenge, the page will reload but no "altcha" input will be sent on the request
I have implemented a "auto-submit" feature on my site using the "verified" event of the widget but the server is not receiving any input.
On the past I opened a issue (#10) because the hidden input was not created when triggering the "verified" event. This issue has again been introduced.
If I submit the form on the next tick, inside a setTimeout with delay 0, the input is received on the server.
How to reproduce the issue, create a form and add the following altcha widget.
Create a script (I'm using typescript) to initialize altcha.
Open the html and complete the challenge, the page will reload but no "altcha" input will be sent on the request