Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Currently there is no option to enable JavaScript call back attribute to be attached to g-recaptcha div (where all attributes get for recaptcha gets attached to) and there's no other way to do this other than modifying in recaptcha.module file itself.
Attached is patch with hard coded data-callback attribute which calls captchaCB function in global JavaScript namespace. Is it possible to add this field in settings to call different function?
Comment | File | Size | Author |
---|---|---|---|
#27 | no-option-for-data-callback-2822129-27.patch | 2.59 KB | relim |
#26 | 2822129-26-D8.patch | 2.53 KB | selva.swamy@gmail.com |
| |||
#23 | 2822129-23-D8.patch | 2.5 KB | selva.swamy@gmail.com |
| |||
#21 | 2822129-21.patch | 2.5 KB | iyyappan.govind |
#20 | 2822129-20.patch | 2.5 KB | iyyappan.govind |
Comments
Comment #2
rmatsumoto CreditAttribution: rmatsumoto commentedComment #3
yang_yi_cn CreditAttribution: yang_yi_cn commentedbtw this feature is regarding
in https://developers.google.com/recaptcha/docs/verify (Verifying the user's response).
The use case is:
- when page load the form submit button is disabled.
- only when user send the correct answer, the button will be enabled by javascript callback.
Comment #4
yang_yi_cn CreditAttribution: yang_yi_cn commentedComment #12
hass CreditAttribution: hass commentedMaybe patch in #2847732: enable configurable data-callback attribute is a better starting point, but I'm sure it has a serious security issue.
Comment #13
hass CreditAttribution: hass commentedonSuccess
is used in https://www.google.com/recaptcha/api2/demo, but that could conflict in Drupal. We should prefix with the module name to be safe.Comment #14
hass CreditAttribution: hass commentedCan we do this with a Drupal.behaviors or anything else I may never used yet? So that every module can register a callback and there is no need to hardcode it?
Comment #15
malcolm_p CreditAttribution: malcolm_p commentedHere's an updated patch that adds a JS library with the callback function in the api.js to prevent the grecaptcha error. I wouldn't say this is a great solution, but I wanted the grecaptcha.getResponse() to check if a recaptcha was submitted and this allows the JS to be loaded.The callback must be in the global scope so Drupal.behaviors isn't an option.
Comment #16
ljcarnieri CreditAttribution: ljcarnieri at CI&T for CI&T commentedI created a patch that can you configure callback in admin area, if you not fill, no one callback will be add. What do you think?
Comment #17
ljcarnieri CreditAttribution: ljcarnieri at CI&T for CI&T commentedThis patch uses the same solution, but resolve of conflict between the patch: #2493183: Ajax support / Use behaviors for version 8.x-2.3.
Motivation: I'm using the version 8.x-2.3 with this other patched applied by composer.json.
Comment #18
leofishman CreditAttribution: leofishman commentedThis may be a silly question, but the callback function should be in a global scope? I can't get reCaptcha to see it.
thanks
Comment #19
iyyappan.govindHi Folks, I tried to apply the #17 patch and I already applied the #2493183: Ajax support / Use behaviors for 2.x . But I got failed to apply patch.
So I rerolled the patch with the stable version of the module.
Comment #20
iyyappan.govindHi Folks uploaded wrong patch. Here is the correct one.
Comment #21
iyyappan.govindThe previous patch has syntax errors. Sorry for that. I updated the patch.
Comment #22
selva.swamy@gmail.com CreditAttribution: selva.swamy@gmail.com as a volunteer and commentedLooks like there are still some issues with patch as testing failed. Kindly update and mark "Needs Review".
Comment #23
selva.swamy@gmail.com CreditAttribution: selva.swamy@gmail.com as a volunteer and commentedUpdated is the corrected patch which has been re-rolled. Also tested this feature and it is working as expected. I think after another review this issue can be marked as RTBC.
Comment #24
selva.swamy@gmail.com CreditAttribution: selva.swamy@gmail.com as a volunteer and commentedComment #25
selva.swamy@gmail.com CreditAttribution: selva.swamy@gmail.com as a volunteer and commented@hass Could you please review the patch in comment#23?
Comment #26
selva.swamy@gmail.com CreditAttribution: selva.swamy@gmail.com as a volunteer and commentedUpdated patch with length limited to 40 characters.
Comment #27
relim CreditAttribution: relim commentedRerolled patch to work with 3.x branch
Comment #28
AnybodyCould someone please prepare this as MR for 8.x-3.x and 4.x for easier review and merge?