8000 Regression | Hidden input not created when dispatching "verified" event · Issue #70 · altcha-org/altcha · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Regression | Hidden input not created when dispatching "verified" event #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
alexbcberio opened this issue Oct 18, 2024 · 1 comment
Closed

Comments

@alexbcberio
Copy link

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.

<altcha-widget
    challengeurl="<challengeUrl>"
    name="altcha"
    data-submit-verified
></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

@ovx
Copy link
Contributor
ovx commented Oct 19, 2024

Hi, thanks for reporting, this has been there for a while. Fixed in version 1.0.6 and E2E test added to cover this.

@ovx ovx closed this as completed Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0