Skip to content
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

Delete the captcha registration after retrieving data in Comment/Add and Message/Reply #4417

Merged
merged 1 commit into from
Jul 26, 2021

Conversation

TimWolla
Copy link
Member

When a validation error is encountered, a new template with a new captcha will
be sent. However the logic within the captcha controller prevents a callback
from being added for a specific captcha ID if one is already registered. This
leads to the previous captcha callback being reused for another attempt.

This does not work, because a single instance of reCAPTCHA may only be used
once, thus erroring out if the callback is invoked a second time.

Fix this issue by deleting the captcha callback once we used it once. Upon
another failure another template will be sent, re-registering a new and valid
captcha.

It was also considered caching the return value, however this will cause issues
if the user mistypes a captcha as they will be unable to correct the error, due
to the same value being returned on the next attempt.

Ideally the getData() function would automatically delete the callback,
making it a single-use callback by design. This might break API users relying
on this current (broken) behavior, though.

The whole (AJAX) CAPTCHA API looks broken beyond repair. It also relies on the
jQuery parts being available. It should be cleanly refactored in a future
version.

…and Message/Reply

When a validation error is encountered, a new template with a new captcha will
be sent. However the logic within the captcha controller prevents a callback
from being added for a specific captcha ID if one is already registered. This
leads to the previous captcha callback being reused for another attempt.

This does not work, because a single instance of reCAPTCHA may only be used
once, thus erroring out if the callback is invoked a second time.

Fix this issue by deleting the captcha callback once we used it once. Upon
another failure another template will be sent, re-registering a new and valid
captcha.

It was also considered caching the return value, however this will cause issues
if the user mistypes a captcha as they will be unable to correct the error, due
to the same value being returned on the next attempt.

Ideally the `getData()` function would automatically delete the callback,
making it a single-use callback by design. This might break API users relying
on this current (broken) behavior, though.

The whole (AJAX) CAPTCHA API looks broken beyond repair. It also relies on the
jQuery parts being available. It should be cleanly refactored in a future
version.
@TimWolla TimWolla added the Bug label Jul 26, 2021
@TimWolla TimWolla requested a review from dtdesign July 26, 2021 12:52
@dtdesign dtdesign merged commit 48f5ede into 5.4 Jul 26, 2021
@dtdesign dtdesign deleted the captcha-delete-after-use branch July 26, 2021 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants