Enhance CAPTCHA Validation in captcha.module to Expose Response Validity Status

Created on 11 March 2024, 9 months ago
Updated 13 March 2024, 8 months ago

Problem/Motivation

The captcha_validate function in captcha.module sets a flag indicating the validity of the CAPTCHA response but does not expose this information to form field callbacks or custom validation handlers. This restricts the ability to perform certain actions based on the CAPTCHA validation status.

Steps to reproduce

1. Submit a form with a CAPTCHA element.
2. Observe the inability to access the CAPTCHA validation status in form field callbacks or custom validation handlers.

Proposed resolution

Add a new key 'captcha_response_is_valid' to the $form_state array and set its value based on the result of CAPTCHA validation. This will allow form field callbacks and custom validation handlers to access the CAPTCHA validation status and perform actions accordingly.

After interaction with an Ajax field with callback, the captcha is triggered, but if the captcha fails for example the callback flow continues, with this new variable available you can check the value on the callback flow and decide what to do.
Captcha and Recpatcha have issues with the Ajax forms and field callback. For this solution, we use recaptcha_v3 and captcha with the config Persistence: Omit challenges in a multi-step/preview workflow once the user successfully responds to a challenge.

Remaining tasks

Implement the proposed solution by adding the 'captcha_response_is_valid' key to the $form_state array in the captcha_validate function.

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Feature request
Status

Active

Version

2.0

Component

Captcha API (captcha)

Created by

🇧🇷Brazil opauwlo

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024