Google is coming out with a new option for the reCAPTCHA service: https://developers.google.com/recaptcha/docs/invisible

It would be cool if we could have the option to use the invisible widget with this module. It doesn't look like there's much of a difference in markup for the invisible widget.

TODO:

  • The Invisible reCAPTCHA requires JavaScript and has no support for browsers without JavaScript enabled. This means the NOSCRIPT fallback no longer works and need to be removed if invisible captcha is used.
CommentFileSizeAuthor
#206 recaptcha-ajax-2493183-164+nocaptcha-2852269-206.patch18.7 KBhswong3i
#203 recaptcha-ajax-2493183-164+nocaptcha-2852269-203.patch19.59 KBcgmonroe
#200 recaptcha-ajax-2493183-164+nocaptcha-2852269-200.patch14.09 KBcgmonroe
#199 interdiff-2852269-165-199.txt581 bytesksenzee
#199 recaptcha-ajax-2493183-164+nocaptcha-2852269-199.patch21.22 KBksenzee
#199 recaptcha-nocaptcha-2852269-199.patch20.3 KBksenzee
#196 recaptcha-2852269-196.patch13.72 KBgugalamaciek
#191 Screen Shot 2020-04-07 at 12.04.35 PM.png714.46 KBveronicaSeveryn
#191 Screen Shot 2020-04-07 at 12.03.30 PM.png727.76 KBveronicaSeveryn
#187 recaptcha-2852269-185-7.x-187.patch13.7 KBgoron
#185 interdiff-2852269-174-185.txt803 bytesaprice42
#185 recaptcha-2852269-185-7.x_0.patch13.73 KBaprice42
#180 recaptcha-nocaptcha-2852269-180.patch20.26 KBhswong3i
#180 recaptcha-ajax-2493183-160+nocaptcha-2852269-180.patch16.87 KBhswong3i
#175 recaptcha-2852269-174-7.x.patch13.66 KBveret
#174 recaptcha-2852269-174-7.x.patch10.29 KBveret
#172 recaptcha-ajax-2493183-164+nocaptcha-2852269-165_2.patch21.19 KBtimcosgrove
#171 recaptcha-ajax-2493183-164+nocaptcha-2852269-165.patch21.64 KBtimcosgrove
#169 recaptcha-invisible-2852269-169-7.x.patch8.61 KBbjaxelsen
#165 interdiff-2852269-151-165.txt749 byteshswong3i
#165 recaptcha-nocaptcha-2852269-165.patch20.27 KBhswong3i
#165 recaptcha-ajax-2493183-160+nocaptcha-2852269-165.patch16.88 KBhswong3i
#164 recaptcha-nocaptcha-2852269-164-reroll.patch19.77 KBmr.york
#163 recaptcha-nocaptcha-2852269-163-reroll.patch0 bytesmr.york
#162 interdiff-2852269-160-161.txt493 bytesmr.york
#162 recaptcha-2852269-161-invisible-recaptcha-and-ajax-D7.patch12.21 KBmr.york
#160 recaptcha-2852269-160-invisible-recaptcha-and-ajax-D7-reroll.patch12.02 KBmr.york
#157 recaptcha-2852269-157-invisible-recaptcha-and-ajax-D7.patch12.02 KBTimRutherford
#157 interdiff-2852269-124-157.txt4.74 KBTimRutherford
#151 recaptcha-nocaptcha-2852269-151.patch19.82 KBChizh273
#151 recaptcha-ajax-2493183-156+nocaptcha-2852269-151.patch16.92 KBChizh273
#151 interdiff-2852269-149-151.txt773 bytesChizh273
#149 recaptcha-nocaptcha-2852269-149.patch19.68 KBhswong3i
#149 recaptcha-ajax-2493183-156+nocaptcha-2852269-149.patch16.79 KBhswong3i
#149 diff-148-149.txt1.71 KBhswong3i
#148 recaptcha-ajax-2493183-136+nocaptcha-2852269-148.patch16.79 KBhswong3i
#148 recaptcha-nocaptcha-2852269-148.patch19.69 KBhswong3i
#148 interdiff-141-148.txt2.88 KBhswong3i
#144 interdiff-141-144.txt684 bytesjames.williams
#144 recaptcha-nocaptcha-2852269-144.patch19.87 KBjames.williams
#141 recaptcha-nocaptcha-2852269-141.patch19.75 KBhswong3i
#141 recaptcha-ajax-2493183-136+nocaptcha-2852269-141.patch17.96 KBhswong3i
#141 interdiff-140-141.txt763 byteshswong3i
#140 interdiff-139-140.txt666 byteshswong3i
#138 interdiff-136-139.txt579 byteshswong3i
#140 recaptcha-nocaptcha-2852269-140.patch19.9 KBhswong3i
#140 recaptcha-ajax-2493183-136+nocaptcha-2852269-140.patch16.85 KBhswong3i
#138 recaptcha-ajax-2493183-128+nocaptcha-2852269-139.patch16.89 KBhswong3i
#138 recaptcha-nocaptcha-2852269-139.patch20.1 KBhswong3i
#136 recaptcha-nocaptcha-2852269-136.patch19.86 KBhswong3i
#136 recaptcha-ajax-2493183-127+nocaptcha-2852269-136.patch16.65 KBhswong3i
#126 recaptcha-ajax-2493183-115+nocaptcha-2852269-126.patch16.16 KBhswong3i
#124 recaptcha-2852269-124-invisible-recaptcha-and-ajax-D7.patch12.76 KBsokru
#123 2852269-123-invisible-recaptcha-and-ajax-D7.patch10.18 KBsokru
#122 recaptcha-ajax-2493183-114+nocaptcha-2852269-122.patch15.82 KBhswong3i
#121 recaptcha-2852269-121-compaibility-with-2493183-111.patch15.76 KBjames.williams
#120 recaptcha-2852269-120-invisible.patch15.49 KBjames.williams
#120 interdiff-2852269-97-120.txt2.94 KBjames.williams
#117 recaptcha-8.x-2.x-invisible-option-2852269-97-compatibility-with-2493183-110.patch15.11 KBjofitz
#113 recaptcha-8.x-2.x-invisible-option-2852269-97-compatibility-with-2493183.patch15.05 KBGaëlG
#108 2852269-108-invisible-recaptcha-and-ajax-D7--interdiff-vs-61.patch9.05 KBjedihe
#108 2852269-108-invisible-recaptcha-and-ajax-D7.patch14.02 KBjedihe
#106 2852269-106-invisible-recaptcha-and-ajax-D7--interdiff-vs-61.patch9.03 KBjedihe
#106 2852269-106-invisible-recaptcha-and-ajax-D7.patch13.99 KBjedihe
#101 2852269-101-invisible-recaptcha-and-ajax-D7--interdiff-vs-61.patch9.03 KBjedihe
#101 2852269-101-invisible-recaptcha-and-ajax-D7.patch13.99 KBjedihe
#97 interdiff-93-97.txt1.2 KBgg4
#97 recaptcha-8.x-2.x-invisible-option-2852269-97.patch14.64 KBgg4
#96 interdiff-93-95.txt1.2 KBgg4
#93 recaptcha-8.x-2.x-invisible-option-2852269-93.patch13.92 KBhswong3i
#89 protected-by-recaptcha.png111.51 KBesod
#87 recaptcha-no-contact.png137.07 KBesod
#85 no-recaptcha.png134.51 KBesod
#85 invisible.png109.27 KBesod
#61 2852269-61-invisible-recaptcha-D7--interdiff-vs-58.patch5.83 KBjedihe
#61 2852269-61-invisible-recaptcha-D7--interdiff-vs-57.patch7.87 KBjedihe
#61 2852269-61-invisible-recaptcha-D7.patch13.09 KBjedihe
#60 2852269-60-invisible-recaptcha-D7--interdiff-vs-58.patch5.7 KBjedihe
#60 2852269-60-invisible-recaptcha-D7--interdiff-vs-57.patch7.73 KBjedihe
#60 2852269-60-invisible-recaptcha-D7.patch12.96 KBjedihe
#59 2852269-59-invisible-recaptcha-D7--interdiff-vs-58.patch5.66 KBjedihe
#59 2852269-59-invisible-recaptcha-D7--interdiff-vs-57.patch7.69 KBjedihe
#59 2852269-59-invisible-recaptcha-D7.patch12.92 KBjedihe
#58 2852269-58-invisible-recaptcha-interdiff-vs-57.patch2.29 KBjedihe
#58 2852269-58-invisible-recaptcha-D7.patch9.63 KBjedihe
#57 2852269-57-invisible-recaptcha.patch7.33 KBjedihe
#56 recaptcha-invisible-option-2852269-56.patch13.98 KBid.aleks
#54 recaptcha-invisible-option-2852269-52.patch6.66 KBid.aleks
#52 Google reCaptcha module problem.PNG12.53 KBSuperbank
#48 recaptcha-invisible-without-2852269-48-7.x-2.x-dev.patch13.4 KBShawnRong
#42 recaptcha-invisible-without-ajax-form-submit-2852269-42-7.x-2.x.patch11.9 KBShawnRong
#39 recaptcha-invisible-without-ajax-form-submit.patch8.7 KBmozh92
#36 invisible_option-2852269-36.patch5.62 KBMatroskeen
#36 interdiff-2852269-24-2852269-36.txt1.69 KBMatroskeen
#33 interdiff-2852269-24-2852269-33.txt526 bytesMatroskeen
#33 invisible_option-2852269-33.patch5.53 KBMatroskeen
#24 invisible_option_8_x_2_x_dev-2852269-15.patch5.55 KBhass
#3 invisible_recaptcha.patch3.51 KBAnonymous (not verified)
#6 recaptcha_implement_invisible_recaptcha.patch5.4 KBbobdekinder
#8 invisible_option-2852269-8.patch3.64 KBchgasparoto
#14 invisible_option_8_x_2_x_dev-2852269-14.patch5.56 KBchgasparoto
#15 invisible_option_8_x_2_x_dev-2852269-15.patch5.55 KBchgasparoto
#15 interdiff-2852269-14-15.txt798 byteschgasparoto
#17 recaptcha-7.x-2.2.patch3.79 KBBedstvie

Issue fork recaptcha-2852269

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

amklose created an issue. See original summary.

hass’s picture

looking for your patch...

Anonymous’s picture

FileSize
3.51 KB

Here is a quick patch for testing which adds an 'invisible' option to the size setting.

Anonymous’s picture

I've added a patch which adds a new 'invisible' size to the configuration. Make sure you also disable the display of the CAPTCHA description.

hass’s picture

Status: Active » Needs work
bobdekinder’s picture

Hi, i tested out the patch provided by VacuumWizaard. But I think a part about the actual form submission is missing. I therefore wrote my own patch based on his. Would love some feedback ...

inovegil’s picture

I'm trying to patch with first the second, then the first file, the module on a working D7 site and I cannot achieve that. Perhaps I should apply it over d8 or directly on the repo? Anyway if it isn't too difficult would be interesting to officially add support for this. Thanks in advance by your help.

chgasparoto’s picture

I made this patch based on @bobdekinder code, with some little improvements.
This is for version 7.x-2.0, once the issue for it was closed earlier (https://www.drupal.org/node/2859577).

Please review.

Thanks!

hass’s picture

D8 first, than backports. We always write patches against DEV.

Hiding bad patches.

inovegil’s picture

@chgasparoto #8 I don't achieve to get this running. I've applied the patch but the options don't appear as modified in recaptcha.admin.inc. I've already reinstalled the module. Ideas? Thanks. Thanks @hass #9.

chgasparoto’s picture

@hass alright, thanks!

@inovegil did you look up on size option? I got this running on a simplytest.me instance without any problems.

inovegil’s picture

Yes I did. The options are normal and compact. I'll try completely erasing and reinstalling. Thanks.

inovegil’s picture

I tried that in simplytest.me it works fine, It's strange because uninstalling and erasing the module (captcha and recaptcha) and then reinstalling them the option is not appearing. One posible reason is that my site is in spanish but I added english, changed the language of the page and the box size was the same options. It's really strange. I tried applying the patch both with patch and git apply without errors. Thanks.

chgasparoto’s picture

@inovegil That's weird. Later I'll try with another language and I'll let you know.

I wrote a patch for the dev version.

Please review.

Thanks!

chgasparoto’s picture

Re-uploading the patch.

I made a mistake forgetting right blank spaces on Badge options array.

chgasparoto’s picture

@inovegil I tested with a Portuguese site and worked fine too. Did you get any errors?

Bedstvie’s picture

integrated your patch to Drupal 7

hass’s picture

Why is testbot not running on the patches? :-(

hass’s picture

D7 uninstall code is missing.

inovegil’s picture

Hello. It seems that there isn't any error. It's very strange, because on all my tests outside this site it worked properly. Regards.

inovegil’s picture

Hide the chgasparoto patch with errors (8.x). He said that they reuploaded the patch dued to mistakes.

levmyshkin’s picture

I tried #17 patch, but it doesn't work for me. It shows always:
The answer you entered for the CAPTCHA was not correct.

I'm not sure why it happens. Firstly I think invisible reCaptcha works only with https, I tested it on local instance without https:
https://developers.google.com/recaptcha/docs/invisible

The script must be loaded using the HTTPS protocol and can be included from any point on the page without restriction.

Secondary I'm not how it should work. Follow docs save/submit button must have attributes:
class="g-recaptcha" data-sitekey="your_site_key" data-callback='onSubmit'

But now I see another button has the same attributes, not save/submit button.

mchaplin’s picture

Will the Invisible reCAPTCHA option be incorporated into a D7 version of this module?

Is there a time frame for that?

Thanks Mike

Status: Needs review » Needs work

The last submitted patch, 24: invisible_option_8_x_2_x_dev-2852269-15.patch, failed testing.

hass’s picture

Failing patches cannot committed.

hass’s picture

We should add a note that people should uncheck Add a description to the CAPTCHA in CAPTCHA settings or an empty fieldset with just a bit confusing text is shown.

hass’s picture

hass’s picture

Issue summary: View changes
hass’s picture

Component: reCAPTCHA Captcha » Invisible reCAPTCHA
thedotwriter’s picture

#17 works fine for a simple form.

But it does not work when two forms use invisible reCAPTCHA on the same page.

To be able to make it work, I had to do a few things:

1. Apply the following patch to enable reCAPTCHA to be set on two forms in the same page: https://www.drupal.org/node/1833822#comment-11430341

2. Modify the code of the patch like I suggested here: https://www.drupal.org/node/1833822#comment-12034233

3. Modify line 54 of recaptcha.invisible.js :
grecaptcha.execute();
by:
grecaptcha.execute(Drupal.behaviors.recaptcha.widgets[$('.g-recaptcha[data-size="invisible"]', $form).attr('id')]);

That way, you'll make sure reCATPCHA executes the right widget and not the first to have been defined when loading the page (without the widget ID as argument, grecaptcha.execute() automatically fallback to the first defined CAPTCHA).

Sorry, I did not do a patch, I'm not sure how that works and I'm lacking time. I still wanted to throw the solution out there though, it may help a few folks.

Cheers

loze’s picture

I tried the patch in #17 as well as the changes suggested in #31
The captcha badge shows up on the form, but on submit I get "The answer you entered for the CAPTCHA was not correct"

I'm getting this in the logs:
"post blocked by CAPTCHA module: challenge reCAPTCHA (by module recaptcha), user answered "Google no captcha", but the solution was "1""

My fault, I had applied the patch incorrectly.
#17 Appears to be working in my case.

Matroskeen’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 33: invisible_option-2852269-33.patch, failed testing.

Matroskeen’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 36: invisible_option-2852269-36.patch, failed testing.

mozh92’s picture

hass’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 39: recaptcha-invisible-without-ajax-form-submit.patch, failed testing.

ShawnRong’s picture

ShawnRong’s picture

I had integrated the new Google Invisible reCAPTCHA options for Drupal 7.And it supports multiple forms in one page.In the recaptcha-customize.js file, Users can rewrite two functions before or after Google reCAPTCHA widget rendered.Here's my patch:

ShawnRong’s picture

I had integrated the new Google Invisible reCAPTCHA options for Drupal 7.And it supports multiple forms in one page.In the recaptcha-customize.js file, Users can rewrite two functions before or after Google reCAPTCHA widget rendered.Here's my patch:

ShawnRong’s picture

Status: Active » Needs review

I had integrated the new Google Invisible reCAPTCHA options for Drupal 7.And it supports multiple forms in one page.In the recaptcha-customize.js file, Users can rewrite two functions before or after Google reCAPTCHA widget rendered.(ps.Please ignore my last three comments,I was really confused with the drupal org issue rules.)Here's my patch:

Status: Needs review » Needs work
hass’s picture

Version: 7.x-2.x-dev » 8.x-2.x-dev
ShawnRong’s picture

Status: Needs work » Needs review

@hass
I had updated the new Google Invisible reCAPTCHA options into the 7.x version.Can you merge the patch into the development release?

Status: Needs review » Needs work

The last submitted patch, 48: recaptcha-invisible-without-2852269-48-7.x-2.x-dev.patch, failed testing.

hass’s picture

  1. Failing patches cannot committed.
  2. D7 can only committed after D8 has been committed.
Superbank’s picture

I am new to Drupal.

I just wanted to launch my own blog and installed Drupal 7.54.

Everything was fine until I installed the Google reCaptcha module from here: https://www.drupal.org/project/google_recaptcha

I have configured reCaptcha correctly, entered my web site secret and public keys.

However now I lost my admin access to Drupal because there is probably a bug in this reCaptcha module from here: https://www.drupal.org/project/google_recaptcha

After I pass the Captcha chalenge and enter correctly my Admin name and password I always get this error:

Notice: Undefined index: timeout-or-duplicate in function g_ask_google() (line 118 in file /home/superbank/www/www/blog/sites/all/modules/google_recaptcha/google_recaptcha.under_hood.inc).
Google reCAPTCHA does not accept this submission. Try again please, or contact to Site support services.

Only local images are allowed.

If you cannot see the image please click HERE

As I'm not able to log in as Administrator now I cannot disable the Drupal reCaptcha module.

As a result my Drupal web site is dead now.

I need an urgent advice on how to fix this annoying issue.

id.aleks’s picture

Status: Needs work » Needs review
FileSize
6.66 KB

I have refined a patch of Matroskeen (Thanks for your work =) ) for D8, that was added here #36. Tested it with Form API Examples, seems it works both on ajax and non-ajax form. Please, test it again.

hass’s picture

There is a typo in recapthcaOnInvisibleSubmit. I guess that the noscript code no longer works and may need to be removed. Not tested.

id.aleks’s picture

Hass, I have updated patch according to you comment. Seems, that reCaptcha doesn't work at all with disabled javascript option. So I removed completely that feature from module. Actually, I think that we need some features if javascript is disabled, but not sure if it's related to this issue. Moreover, I have updated recaptcha.invisible.js code, due to some issues in it. Please test it.

jedihe’s picture

Version: 8.x-2.x-dev » 7.x-2.x-dev
FileSize
7.33 KB

#39 didn't apply cleanly, re-rolling to fix that problem. Re-roll was verified with a visual diff tool: no code changes, only diff metadata and file paths were updated.

Switching to D7 to run tests.

jedihe’s picture

Version: 7.x-2.x-dev » 8.x-2.x-dev

Just 1 warning about coding standards, will leave it like that. Manual testing is still to be done.

Switching to 8.x while I perform manual testing and perform some other adjustments (we may need to call .reset() as done in #2493183: Ajax support / Use behaviors).

jedihe’s picture

Hiding interdiffs.

hass’s picture

Have you ever seen the test with select box next to file upload button?

mozh92’s picture

this in not work with ajax, I try patch https://www.drupal.org/files/issues/2493183-71-ajax-support.patch with #61

jedihe’s picture

@hass: hey! I've seen it :), it only offers a single test setup, but I need more comprehensive testing than that. Any other way you know to get multiple test envs without (temporarily) switching the issue to 7.x?

Some results from manual testing for #61 (D7, using Examples module):
reCaptcha V2:

  • Works fine for normal forms (e.g. login form in block).
  • Works fine for AJAX-enabled forms.
  • Two forms with reCaptcha get a separate reCaptcha widget.
  • A valid reCaptcha is "cached" when submitting the login form; so if there are validation errors, no reCaptcha widget is shown again (I'm guessing it gets stored in the form cache?).

Invisible reCaptcha:

  • Click handler to trigger background fetching of reCaptcha is not triggering for AJAX-enabled submit (try examples module, /examples/ajax_example/wizard path). This is related to Drupal's AJAX using mousedown to trigger the AJAX submission and disabling the click to prevent other problems. See https://drupal.stackexchange.com/questions/11638/how-to-programmatically...
  • Multiple forms with invisible reCaptcha generate multiple badges (icon at bottom left/right); subtle, but ugly.

In summary:

  • reCaptcha V2: multiple widgets working, AJAX-enabled forms working.
  • invisible reCaptcha: works for normal forms, doesn't yet work for AJAX-enabled submit buttons (it may be possible to get it working by overriding Drupal.ajax.prototype.beforeSubmit()).

Given how difficult it seems to be to get the invisible reCaptcha working with AJAX-enabled forms, I won't even attempt it.

jedihe’s picture

@mozh92: #61 and https://www.drupal.org/files/issues/2493183-71-ajax-support.patch can not be applied together. I think #61 does everything that https://www.drupal.org/files/issues/2493183-71-ajax-support.patch does (only exception may be calling .reset() when the behavior is triggered again in a form that was already processed, but I don't yet know why is that necessary).

jedihe’s picture

Using Drupal.ajax.prototype.beforeSubmit() for this may require https://www.drupal.org/node/1907932; this is in order to halt the AJAX submission while the reCaptcha request is performed asynchronously; later, the callback can be used to re-trigger the AJAX submission, but this time with a flag that should let it run in its entirety.

jedihe’s picture

mozh92’s picture

Given how difficult it seems to be to get the invisible reCaptcha working with AJAX-enabled forms, I won't even attempt it.

I try this do, but I no have high experience

edchan’s picture

I'm using 7.x-2.2 and would like to implement the invisible reCaptcha. I've used #17 patch but I'm getting "The answer you entered for the CAPTCHA was not correct." How to make this work? Thanks.

mikemadison’s picture

The invisible captcha patches and seems work fine on the 8.2.x-dev branch. Are there specific concerns other than being able to add an invisible captcha and seeing that it triggers validation when it should (and doesn't otherwise)?

jerry’s picture

If this is working acceptably now, at least for conventional single-form applications, I'd love to see it back-ported to D7 soon. I have a lot of D7 clients that I need to migrate from Mollom before it shuts down, and I expect that I'm hardly the only one in that situation.

hass’s picture

@jerry: you can still use the module. No need to wait for invisible recaptcha.

I remember some people reported issues with above patch that are not fixed yet.

jerry’s picture

No need to wait for invisible recaptcha.

Understood (and thanks), but I hope to wait for the invisible recaptcha if possible as it provides a user experience closer to Mollom's (no visible captcha in most cases).

mikemadison’s picture

the patches worked for me!

mikemadison’s picture

Status: Needs review » Reviewed & tested by the community
id.aleks’s picture

I have almost finished applying that patch for webforms form. I will try to complete it and update here in near feature.

hass’s picture

Status: Reviewed & tested by the community » Needs work

There have been bugs / issues reported with this patch.

id.aleks’s picture

Issue tags: +LutskGSW18
id.aleks’s picture

Assigned: Unassigned » id.aleks
mstef’s picture

Is this any different than https://drupal.org/project/antibot ?

id.aleks’s picture

Is this any different than https://drupal.org/project/antibot ?

@mstef antibot uses another method to indicate a bot. For example, it waits for a mouse to move to indicate that the visitor is human. This module provides a Google Recaptcha functionality.

esod’s picture

FileSize
109.27 KB
134.51 KB

The patch is causing us to not be able to contact reCAPTCHA. With 8.x-2.x-dev ((HEAD detached at 572d857)) ...

Invisible configured

no recaptcha

When I change the widget size back to Normal, reCAPTCHA is contacted again.

dandaman’s picture

FileSize
53.22 KB

esod,

When you register for a new site with Google, you have to choose between reCAPTCHA V2 or Invisible reCAPTCHA. So maybe you have to get a new API key for Invisible to work?

Google's reCAPTCHA registration form screenshot.

Which also brings up a question: Can an API request tell what type it is? So maybe we could even detect the type and display it accordingly? (I'm not sure this is how it works... I'm just noticing how it looks from the above registration screen--that it seems you sign up for an API key for the classic reCAPTCHA or the Invisible reCAPTCHA.)

esod’s picture

FileSize
137.07 KB

@dandaman, redoing my keys with Invisible reCAPTCHA does get my site contacting reCAPTCHA again using the widget size invisible. Thanks.

However, the reCAPTCHA is never invisible and after ten page reloads it never launches the reCAPTCHA widget itself.

esod’s picture

esod’s picture

FileSize
111.51 KB

Please ignore the screen shot recaptcha-no-contact.png. It's there by mistake.

I am seeing g-recaptcha on the page here:

<input data-drupal-selector="form-nfpouo2wpk2xnrsiiykat1hajjv8hll0fffzzcucbag" type="hidden" name="form_build_id" value="form-NfpoUO2Wpk2XnrsIiyKat1hAJjV8Hll0ffFzZCucBAg" />
<input data-drupal-selector="edit-user-login-form" type="hidden" name="form_id" value="user_login_form" />
   <div class="captcha js-form-wrapper form-wrapper details" open="open"><h4 role="button" aria-expanded="true" aria-pressed="true" class="summary">CAPTCHA</h4><div class="details-wrapper"><div class="details-description">This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.</div><input data-drupal-selector="edit-captcha-sid" type="hidden" name="captcha_sid" value="329245" />
<input data-drupal-selector="edit-captcha-token" type="hidden" name="captcha_token" value="c67585fc88267b5b4235ef3e8b454120" />
<input data-drupal-selector="edit-captcha-response" type="hidden" name="captcha_response" value="Google no captcha" />
<div class="g-recaptcha" data-sitekey="6LegHkYUAAAAAL9wIc5seYwv65n1FZ7zrar2z2ma" data-theme="light" data-type="image" data-size="invisible" data-badge="bottomright" data-callback="recaptchaOnInvisibleSubmit"></div></div>
</div>

As well as the protected by reCAPTCHA sticker.

protected-by-recaptcha

Now if I can just get the reCAPTCHA widget itself to fire...

kyberman’s picture

I tested patch #56 and it works without problems.

gerzenstl’s picture

I applied patch #56 and it works without problems. Thanks!

esod’s picture

We're also going to use this patch, but not on a modal or in an ajax form.

Note that the reCAPTCHA only fires when Google decides you're a bot or a mischief maker.

It's recommended (not sure by whom; maybe Google, maybe a post I read that seemed knowledgeable) to use CSS to hide the recaptcha badge. Which makes sense. A snippet like this is working for us:

/* Hides the recaptcha badge with css*/
.g-recaptcha {
  display: none;
}

You can also uncheck "Add a description to the CAPTCHA" at /admin/config/people/captcha and the result is truly invisible reCAPTCHA.

hswong3i’s picture

Update #56 via latest 8.x-2.x-dev

davemybes’s picture

Status: Needs work » Reviewed & tested by the community

Works great even with latest 2.3 release. Thanks!

hass’s picture

Status: Reviewed & tested by the community » Needs work
gg4’s picture

Spent a bit of time with this issues trying to track down the remaining open issues...

I addressed #27 in a new patch attached here.

#31 Multiple invisible reCAPTCHAs on a single page is still an issues, but maybe should be blocked by #1833822. This issue can be reproduced by using Drupal's standard install profile, and enabling the User login block in the Sidebar first region on the Website feedback form, and enabling the invisible reCAPTCHA on both. User login will fail.

Ajax form submission on a form provided by Webform module seemed to work fine.

If we can round up any other open issues, I can take a pass at resolving them.

gg4’s picture

gg4’s picture

Status: Needs work » Needs review

Needs review for the testbot.

gerzenstl’s picture

Ajax form submission on a form provided by Webform module seemed to work fine.

@bonus, I think that is related on what is reported on #2493183.

The patch looks good.

The last submitted patch, 17: recaptcha-7.x-2.2.patch, failed testing. View results

jedihe’s picture

Starting from #61, I implemented AJAX support for normal and compact reCAPTCHA (invisible is too hard, AFAIK). Patch attached, also attaching interdiff vs. #61.

Tested on a form loaded inside an AJAX modal (ctools modal, leveraging modal_forms module).

Apologies if this isn't the best issue to post this, I considered #2493183, but given I started from a patch from here it seemed more natural to post it here for proper context.

jedihe’s picture

Version: 8.x-2.x-dev » 7.x-2.x-dev

Switching to 7.x-2.x to check if the existing tests still pass. No tests yet for the AJAX functionality, sorry.

jedihe’s picture

Version: 7.x-2.x-dev » 8.x-2.x-dev

7.x tests queued, I guess switching to 8.x-2.x-dev won't interrupt those.

The last submitted patch, 101: 2852269-101-invisible-recaptcha-and-ajax-D7.patch, failed testing. View results

jedihe’s picture

Version: 8.x-2.x-dev » 7.x-2.x-dev

Oh boy, I haven't learned how to talk to the test bot :(. Trying again...

The last submitted patch, 106: 2852269-106-invisible-recaptcha-and-ajax-D7.patch, failed testing. View results

jedihe’s picture

jedihe’s picture

Version: 7.x-2.x-dev » 8.x-2.x-dev
millionleaves’s picture

I just applied the patch in #97 to the latest release version (which is dated after the current -dev version).

It appears to work (how to trigger an captcha challenge when using invisible captcha?), but I when I enabled a description ("prove you're not a robot") and customised it, the Catcha box appeared with that message in it, but no captcha. Not very invisible!

Disabling the description made the form disappear.

Reuben Unruh’s picture

To trigger reCAPTCHA, use the user agent Googlebot/2.1. I think the easiest way to change your user agent without installing a chrome plugin is by creating a new device in Chrome DevTools.

Pawprint’s picture

Re. the patch in #108, I had a bit of a problem integrating this into one of my client's sites - it eventually boiled down to me taking a closer look at this line in recaptcha.invisible.js:

$form.find('input[type="submit"]').click(function (e) {

All the auto-generated forms on this particular client's website actually have <button type="submit"> as their means of submitting the form, however there potentially are other ways to submit a form too:

Button elements with no type attribute
An input with a type of "image"
A button outside the form, linked to the form through the use of the form attribute, e.g.:

<form id="myform">
...
</form>
<button type="submit" form="myform">Submit</button>
GaëlG’s picture

I could not apply #97 because I had already applied the patch from #2493183: Ajax support / Use behaviors. Here's a patch that will apply only if you already applied this one before: https://www.drupal.org/project/recaptcha/issues/2493183#comment-12537531

gg4’s picture

@hass, or anyone else, what else do we need to accomplish in the scope of this issues given #97?

hass’s picture

Fixing the issues that different people have reported. Code seems not stable and reliable.

gg4’s picture

Thanks, @hass. All reported issues are either part of separate reported issues or addressed in my latest patch, I believe. I am very willing to help move this issue forward. Would you want me to start combining issues? Or, do you or anyone else have any other feedback on outstanding bugs in this issue -- I went through all the back comments and not seeing anything specifically called out?

jofitz’s picture

jofitz’s picture

Oops, didn't want to run that patch past the testbot - it's obviously gonna fail.

Status: Needs review » Needs work
james.williams’s picture

I found the following issues with patch 117 / 97:

1) Drupal.Ajax.prototype.beforeSubmit() is totally replaced, so no other module can do similar and 'hook in' to this. So I've ensured the previous version of the function is still called too. (Other replacements for the function ought to always do similar, so it shouldn't matter which order the overrides are made. Even if they don't, let's set a good example.)
2) For me, my ajax behavior binds to the mousedown event before the new one in recaptcha.invisible.js is bound. (Presumably just because ajax.js comes before our JS file in the source order). This means that the beforeSubmit() gets called before the clickedSubmit variable is correctly set, and so the AJAX is never aborted, and thus fails validation (because recaptcha hasn't yet had chance to execute before sending the POST data). So instead of checking clickedSubmit at that point, check for a custom data property, which gets set in the initial each loop that binds our own mousedown/click handlers.
3) There is a use of .ajaxSend() that will run for every time behaviors are attached. So I've avoided that (by setting a data property on the document and only binding when it hasn't previously been set).
4) Some browsers won't support checkValidity() for HTML5 form validation. So only call that if it is available (otherwise, the form is always considered valid enough to submit to the server anyway, i.e. the pre-HTML5 behavior).
5) For those that do support checkValidity(), as the default browser behavior is aborted, the browser may not actually show the HTML5 validation errors. So I've added a call to reportValidity(), which should do this.

james.williams’s picture

hswong3i’s picture

#121 reroll via latest recaptcha-8.x-2.x-dev, apply after ajax patch #114

sokru’s picture

Here's a D7 re-roll #108 against latest dev. But I get following browser console error: `reCAPTCHA couldn't find user-provided function: drupalRecaptchaOnLoad - recaptcha__da.js:426 `.

Edit: Patch missed recaptcha.js and recaptcha.invisible.js

sokru’s picture

sokru’s picture

Manually tested #124 and it seems to be working as expected.

hswong3i’s picture

hswong3i’s picture

Status: Needs work » Needs review

The last submitted patch, 120: recaptcha-2852269-120-invisible.patch, failed testing. View results

The last submitted patch, 123: 2852269-123-invisible-recaptcha-and-ajax-D7.patch, failed testing. View results

Status: Needs review » Needs work
gg4’s picture

Although valuable, all of these combination patch comments are really distracting from moving this issue forward. Does anyone have additional feedback on #97 and what additional outstanding issues need to be addressed?

gg4’s picture

If not, does someone want to RTBC #97?

james.williams’s picture

Status: Needs work » Needs review

@bonus - not #97, no, because of the points I listed in comment #120. Given much of the recent work in this ticket has built upon #2493183: Ajax support / Use behaviors, I suggest getting that one sorted first?

hass’s picture

Nope.

hswong3i’s picture

james.williams’s picture

Thanks @hswong3i, looks fine :-)

hswong3i’s picture

Fixup: as long as noscript support removed, the new $recaptcha_src_fallback no longer required, too ;-)

harveyk’s picture

Hi @hswong3i the recaptcha-nocaptcha-2852269-139.patch works perfectly on both a fresh install added to the login form and on a site with webforms. Thank you!

hswong3i’s picture

hswong3i’s picture

hswong3i’s picture

harveyk’s picture

Hi All,

I had an issue with invisible reCAPTCHA preventing client side validation. I was using jQuery validate and when I would click the submit button no validation would occur. In order to fix this I slightly modified the preventFormSubmit function of recaptcha.invisible.js by checking to see if novalidate was set, as it was with my form.

Old code:


if (form && typeof form.checkValidity === 'function') {

New code:

var novalidate = form.getAttribute('novalidate');
if (form && typeof form.checkValidity === 'function' && !novalidate) {

Now the form successfully validates upon completion of the challenge if it is triggered. Otherwise it validates normally.

I am essentially forcing the captcha to validate before the client side validation runs. Can anyone chime in on this, maybe with a better solution to this problem?

james.williams’s picture

@harveyk good spot, yes, a check needs adding for that attribute.

I've lost track of how the patches are being made in combination with #2493183: Ajax support / Use behaviors. We really need that one progressed towards commit. So due to that, I'm only attaching a single patch & interdiff, sorry!

hass’s picture

Issue tags: +Needs documentation

Please add documentation to all conditions and not so obvious settings in the js files. Something that explains the code in detail and its intention. On many lines I have codewise no idea why the condition exists and what it covers/does. This mostly affects recaptcha.invisible.js. Better write more than less. We need to be able to directly understand the code - without reading every comment in this case why a change was done.

veronicaSeveryn’s picture

Can we also either document somewhere for everyone to remember OR find a better selector for the code referencing to submit buttons assuming they have markup of <INPUT> element?

Several sites I have worked on do have theme alterations which replace <INPUT> with <BUTTON> markup on form submission buttons, and then the whole Recaptcha detection functionality fails, always saying "The answer you entered for the CAPTCHA was not correct." because nothing is in fact being verified with Google on submit.

I keep forgetting about this but and keep banging my head around it for hours until I come back to the same discovery :))

I believe it relates to both patches: D7 and D8

Status: Needs review » Needs work

The last submitted patch, 144: recaptcha-nocaptcha-2852269-144.patch, failed testing. View results

hswong3i’s picture

Patch reroll via latest 8.x-2.x-dev, with #144 changes + minor bugfix (see interdiff)

hswong3i’s picture

Patch #148 reroll via 8.x-2.x-dev...

No interdiff (just diff) could be given due to following error message:

1 out of 4 hunks FAILED -- saving rejects to file /tmp/interdiff-1.dMemyi.rej
interdiff: Error applying patch1 to reconstructed file

How annoying for a child issue for another RTBC issue...

gg4’s picture

Status: Needs review » Reviewed & tested by the community

Just a note that the combo patch from #14 no longer applies.

Chizh273’s picture

Hi guys

I've found a bug with multiple recaptcha on one page. If you connect recaptcha to more them one form, recaptcha validation token always will be added to the first form. And after submit second form you get error 'The answer you entered for the CAPTCHA was not correct.'

I added fix

gg4’s picture

Status: Reviewed & tested by the community » Needs review
gerzenstl’s picture

Patch recaptcha-nocaptcha-2852269-151.patch on #151 works fine.

But as last test shows, recaptcha-ajax-2493183-156+nocaptcha-2852269-151.patch fails to apply the patch. I manually merged the changes between nocaptcha-2852269-151.patch and recaptcha-ajax-2493183-156.patch, but nocaptcha isn´t working on ajax forms.

chOP’s picture

Up until recently we had been using the patch in #97 with

drupal/core : 8.5.6
drupal/webform : 5.0.0-rc18
drupal/recaptcha : 2.3

The no-captcha display for reCAPTCHA stopped working on Webforms using a File upload field after updating to

drupal/core : 8.5.8
drupal/webform : 5.0.0-rc26

I've now tried updating our drupal/recaptcha to use the latest patches above, however the problem remains. We get variations on this ajax alert message, when using a File Upload field button.

An error occurred while attempting to process %URL : Cannot set property options of undefined.

The Ajax error is triggered in Drupal core - docroot/core/misc/ajax.js at line 327

See https://cgit.drupalcode.org/drupal/tree/core/misc/ajax.js?h=8.5.x#n327

Switching back to the default display for reCAPTCHA addresses the issue on the affected forms. This has only hit webform forms using a File Upload field so far.

cbe243’s picture

I tried patch #124 and it doesn't work: "The answer you entered for the CAPTCHA was not correct."
I tried with both the dev and stable version.

D7

TimRutherford’s picture

Hey guys,

I've updated the D7 patch from #124 to work with ajax forms. Tested on latest dev branch with Captcha 7.x-1.5.

cbe243’s picture

I tried the last patch of Tim (#157) and I get "The answer you entered for the CAPTCHA was not correct".

ransomweaver’s picture

I also get "Answer not correct" after submitting: recaptcha dev with patch #157. I do see the recaptcha icon in the lower right corner, so it seems to be initializing.

mr.york’s picture

Status: Needs review » Needs work
mr.york’s picture

mr.york’s picture

Reroll D8 patch.

mr.york’s picture

hswong3i’s picture

Patch #151 reroll via recaptcha-8.x-2.x, also include the new fix as #2493183-160: Ajax support / Use behaviors mentioned:

diff -u b/recaptcha.module b/recaptcha.module
--- b/recaptcha.module
+++ b/recaptcha.module
@@ -71,9 +71,10 @@
             '#value' => 'Google no captcha',
           ];
 
-          // As the validate callback does not depend on sid or solution, this
-          // captcha type can be displayed on cached pages.
-          $captcha['cacheable'] = TRUE;
+          // Prevent "CAPTCHA validation error: unknown CAPTCHA session ID"
+          $captcha['cacheable'] = FALSE;
+          $captcha['form']['captcha_response']['#cache'] = ['max-age' => 0];
+          \Drupal::service('page_cache_kill_switch')->trigger();
 
           // Check if reCAPTCHA use globally is enabled.
           $recaptcha_src = 'https://www.google.com/recaptcha/api.js';
hswong3i’s picture

Status: Needs work » Needs review
hudri’s picture

Installed and manually tested #165 (without ajax) on multiple sites, all work fine.

malcolm_p’s picture

#164 fails for me on an AJAX form under the following conditions:
1. Submit a form with server-side validation that fails. This returns an error message.
2. Correct the error and submit again. The form cannot be submitted.

This appears to be caused by the jQuery(clickedSubmit).unbind('.recaptcha');, removing that line fixes the issue for me. Without this successive validatation attempts are blocked by preventFormSubmit.

For #165 Is the claim that #2219993 created a regression? I'm not seeing that myself, the cacheable captcha element has been working fine.

bjaxelsen’s picture

Updating D7 patch from @mr.york #162

Status: Needs review » Needs work

The last submitted patch, 169: recaptcha-invisible-2852269-169-7.x.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

timcosgrove’s picture

This is a re-roll of the combined patch merging #165 & https://www.drupal.org/project/recaptcha/issues/2493183#comment-12970759, that hopefully applies and passes.

This combined patch does not attempt to address any outstanding items, such as https://www.drupal.org/project/recaptcha/issues/2493183#comment-12947548. It only attempts to merge the two latest working patches for these respective issues. It also does not include the fix described in #160.

timcosgrove’s picture

Updated patch:

1. Removes the test for the fallback asset that https://www.drupal.org/project/recaptcha/issues/2493183#comment-12970759 added, as #165 removes the fallback asset and the other issue doesn't seem to otherwise make use of the fallback.
2. Fixed a number of code style violations.

rmpereira’s picture

I tried the patch #162 with an upload field (ajax) in my form and I get "The answer you entered for the CAPTCHA was not correct".
I use the invisible Recaptcha and I have no javascript/PHP error.

veret’s picture

@rmpereira I had the same issue, because recpatcha event was attached only to 'input', while in my case it had to be attached to form 'button'. It might be similar in your case. You can try attached patch recaptcha-2852269-174-7.x.patch.

Attached you can find updated patch from #162 and #169:

  1. Fixed global captcha + fallback urls
  2. Now recaptcha is looking for both 'input' and 'button' submit elements
  3. Remove hardcoded urls
  4. For each recaptcha submission, response from grecaptcha is checked, and recaptcha is triggered again if needed
  5. Fixed tests
veret’s picture

FileSize
13.66 KB

Updated patch from #174 with fixed paths.

Simon Georges’s picture

Status: Needs work » Needs review

Changing status after some new patches have been posted.

james.williams’s picture

It's not clear if the issue in comment 168 has been addressed yet? The patch in comment 169 did not contain an interdiff and suggest it is just an update of a patch from before comment 168.

Simon Georges’s picture

Indeed… I apologize if I was hasty in changing the status.

hass’s picture

Status: Needs review » Needs work
hswong3i’s picture

I just give a simple reroll to #165 via latest dev...

P.S. Sorry I am not a big fans to add in more fix for this issue...
It already get stuck since 14 Feb 2017...
At least #165 working happily for my client(s) for more then 3 months...
Please kindly let it RTBC...

rmpereira’s picture

@veret Thx for the patch #174 but it does not work completely in my case.

My steps to reproduce the problem :
1) I select a file and i click on the upload file button.
2) The file is uploaded but the form is reload and i have the drupal message "The answer you entered for the CAPTCHA was not correct."
3) I click on the form submit button, the form is validate and i redirected to the confirmation page.

Only the step 2) is problematic.

zkrebs’s picture

Applied #175 on d7-dev, it appears to work on user/login but on a node submission form it still states "The answer you entered for the CAPTCHA was not correct" even after cache cleared.

zkrebs’s picture

Applied #175 on d7-dev, it appears to work on user/login but on a node submission form it still states "The answer you entered for the CAPTCHA was not correct" even after cache cleared.

sanjay.maharjan’s picture

Hi @timcosgrove,
I have applied patch mentioned in #172. Everything is fine except the file upload section in webforms. I have ajax enabled in my webform and while trying to upload a file, it gives me `An error occurred while attempting to process /form/your-webform-with-invisible-recaptch-enabled?element_parents=elements/upload_container/resume&ajax_form=1&_wrapper_format=drupal_ajax: options is undefined`

Is anyone getting this error?
Thank you!

aprice42’s picture

I made a couple of minor adjustments to the D7 patch at #175 to prevent this creating double submissions due to the redundant call to both .mousedown() and .click() in recaptcha.invisible.js

I also added logic to recaptcha.invisible.js to allow for a class .ignore-captcha to be added to a submit element to prevent it from triggering a captcha submission.

jimconte’s picture

I tried applying #180 to latest 8.8.1 but patch does not apply

goron’s picture

Regarding the changes in #185: I don't think it makes sense to only trigger the mousedown event in the onInvisibleSubmit() callback. I think most forms don't submit with mousedown on a button (since that also fires if the mouse is pressed over the button but released outside of it, or the right mouse button is pressed). Using that latest patch didn't work on any forms on a site I tested it with for this reason.

If one event is used, I think it should be click. Or if there's good reason to support both, then some solution can be used to make sure the form is not submitted twice (like maybe - fire mousedown event, in a submit event handler set some state on the form to indicate submission has happened, fire click event only if that state is not set). I'm just not sure whether mousedown event is really needed here. Maybe someone can point to an example where it is?

Attaching a patch that is the same as #185 except using the click event.

danyg’s picture

I tried the patch of #185 comment. Unfortunately, I wasn't able to make it work. I always get the following error message in console: "reCAPTCHA couldn't find user-provided function: drupalRecaptchaOnLoad"
I tried to uncomment that line, the message has been disappeared, but Catcha gives error on submit: "The answer you entered for the CAPTCHA was not correct." (of course I'm not able to give answer for invisible captcha).
What did I miss?
UPDATE: sorry, I didn't notice that added js files went to my root folder, not into the folder of recaptcha. It works for now as I expected, I had to hide the fieldset legend and description by css.

Kris77’s picture

I found this two module:

What do you think?

ShaunDychko’s picture

This is a supported version of reCAPTCHA V3.

veronicaSeveryn’s picture

Still having an issue (mentioned in #155) with Recaptcha JS on webforms that have FILE UPLOAD buttons.

From what I debugged (see screenshots): Recaptcha JS is looking for SUBMIT type button, and these File Upload buttons are falling into the same category and screw JS logic, which doesn’t rely on the proper button in this case. Recaptcha JS finds 3 buttons on the form in my use case. Hence, further processing is not applicable correctly.

I haven't figured out the best way to bypass these buttons. Webform markup/classes might change in the future..
Unless we have to go around with manually adding a .ignore-captcha class to buttons on webforms that don't have to be accounted for (as proposed in #185). Or it can be somehow incorporated into Recaptcha settings (provide an option on admin settings, for example, to exclude File Upload buttons and add form alteration hooks) ?

form sample
console logs

hudri’s picture

Please, please, please stop "fixing" this issue and let it continue to RTBC. I've been using all of @hswong3i's patches for the latest stable 8.x-2.x versions since 2 years on over 50 production sites with a few hundred thousand webform submissions in total and it works really well.

Even if there are outstanding issues, please do not fix them here, but create follow-ups. The current work is ready for production!

TLWatson’s picture

The D8 version maybe, but I'm still having the same issues in D7 as previously mentioned after applying the latest patch.

Users get the "answer not correct" error, the logs say that the user answered "Google no captcha"... and it appears that this is only happening on forms with file uploaders.

alexandru.dumitru’s picture

Current implementation for D8 breaks HTML5 validations.
Steps to reproduce:
1. Create a new webform with required fields
2. Add an invisible captcha to webform
3. Submit webform without filling the required field
4. The form will not submit and focuses on the field but the html5 error is hidden
Expected:
HTML error should be displayed

alison’s picture

Re: #193 and others (and, I'm new to the thread so I apologize if I'm misunderstanding the backstory):
Shouldn't the D7 implementation be in its own thread, or?

gugalamaciek’s picture

I can confirm problems with forms, where files can be attached (see #191). I'm attaching improved patch, which will change this:
var $formSubmit = $('input[type="submit"], button[type="submit"]', $form);

into this:
var $formSubmit = $('.form-actions input[type="submit"], .form-actions button[type="submit"]', $form);

For me it fixes the problem, but I'm not sure if this is the best approach. But I don't have better now.

torotil’s picture

How about splitting out the D7 version into its own issue?

I’ve reviewed #196 and found one additional issue (apart from how file uploads should be handled): On AJAX submit buttons the beforeSubmit() callback is overwritten. For compatibility with other scripts that might do that the original handler should be backed up and called when doing this.

torotil’s picture

I’ve opened #3201620: D7: Integrate invisible captcha to have a clean D7 version and opened a merge request there.

I’ve started with the patch in #185 and #196 and made a few improvements:

  1. Call the original beforeSubmit() handler.
  2. Handle multiple submit-buttons on the same form. They each have their own ID and ajax settings and beforeSubmit() callback.
  3. Alway trigger the original event when resuming the submission.
ksenzee’s picture

Version: 8.x-2.x-dev » 8.x-3.x-dev
Status: Needs work » Needs review
FileSize
20.3 KB
21.22 KB
581 bytes

Now that the D7 patch is in its own issue, here's a new patch for D8/9. The current patch for D8/9 was at #165, and it works well (we've had the combined patch at #172 in production for years) except for the issue brought up in #184 and #191, which is that webform file uploads are broken. This patch addresses that by keeping elements with the formnovalidate attribute out of the recaptcha flow. That's logical anyway, because recaptcha will submit the whole form as soon as it succeeds, and you only want that behavior on the real form submit.

cgmonroe’s picture

The recaptcha-ajax-2493183-164+nocaptcha-2852269-199.patch in #199 does not apply to the new 8.x-3.1 release. The problem is with the test update.

Attached is an updated version that will apply to the new release. I *think* I got the test issues resolved but these may need to be tweaked.

We have been using the patch from 199 with no problems on our sites.

Status: Needs review » Needs work
hudri’s picture

Patch #200 breaks checkbox reCaptchas. If I apply this patch, forms with a checkbox reCaptcha will show this message in the console:

recaptcha__en.js:135
reCAPTCHA couldn't find user-provided function: drupalRecaptchaOnload
cgmonroe’s picture

Status: Needs work » Needs review
FileSize
19.59 KB

Mea Culpa...

Git diff does not include untracked files. So the -200 patch is missing a new recaptcha.library.yml and a couple of files in the js directory. Didn't catch it with our testing because the new files existed in our code and the patch worked without creating them.

Here is a new patch that includes the new required files. This adds back the missing drupalRecaptchaOnload function.

Status: Needs review » Needs work
guardiola86’s picture

Thanks @cgmonroe. That patch works with 9.3 as well

hswong3i’s picture

Status: Needs work » Needs review
FileSize
18.7 KB

Re-roll #203 with 8.x-3.x-dev

Status: Needs review » Needs work
drupov’s picture

3.x is incompatible with https://www.drupal.org/comment/reply/2493183, as mentioned several times above for the 2.x.-branch

(8.x-3.x) ~/Desktop/recaptcha$ patch -p1 < ../recaptcha-ajax-2493183-164+nocaptcha-2852269-206.patch 
patching file config/install/recaptcha.settings.yml
patching file config/schema/recaptcha.schema.yml
patching file js/recaptcha.invisible.js
patching file js/recaptcha.js
patching file migrations/d6_recaptcha_settings.yml
patching file migrations/d7_recaptcha_settings.yml
patching file recaptcha.libraries.yml
patching file recaptcha.module
patching file src/Form/ReCaptchaAdminSettingsForm.php
patching file templates/recaptcha-widget-noscript.html.twig
patching file tests/src/Functional/ReCaptchaBasicTest.php

{8.x-3.x} ~/Desktop/recaptcha$ patch -p1 < ../recaptcha-ajax-support-2493183-258.patch 
The next patch would create the file js/recaptcha.js,
which already exists!  Assume -R? [n] 

smokris made their first commit to this issue’s fork.

smokris’s picture

Status: Needs work » Needs review

I opened an issue fork consisting of hswong3i's patch from comment #206, plus a commit to remove another stray reference to the removed $noscript variable.

NuWans’s picture

I'm on drupal 10 and recaptcha 3.2, the patch is not applicable on this version. Does anyone use it on this version? Is it planned to adapt?
THANKS

dchaffin’s picture

What is the status of this? I would really like to be able to update to reCaptcha v3. Thanks!

roxflame’s picture

@dchaffin, I suggest using this other module while we wait for this to be integrated here
https://www.drupal.org/project/recaptcha_v3

You can use it as the primary captcha, and have it fall back to this module if it fails validation.

Anybody’s picture

@smokris this please needs a rebase.
All others: Once rebased, please test the MR and check if it's working. Can someone help about the documentation, please? (Needs documentation tag)

I hope we can then integrate this soon.

For the next time, I think it might make sense to add such new features as (experimental) separate submodules so we don't have to fear breaking something in production for the existing functionality?

smokris’s picture

Rebased.

Anybody’s picture

@smokris thanks! There's still a TODO in the IS, is that old or still to TBD? Sorry I don't have much time currently, so further community help would speed up the process here for sure.

Anybody’s picture

Status: Needs review » Needs work

albeorte made their first commit to this issue’s fork.

dark05’s picture

Hello :-) It works with ReCaptcha version 3.2.0 and patch
Thanks

OwilliwO’s picture

Sadly, PR 15 diff is not applicable on top of 3.2 stable version.
And the applicable patch from comment #206 is using an undefined variable $noscript (creating a PHP warning).

Here is a quite patch I've applied on top of V3.2 + patch #206.

diff --git a/recaptcha.module b/recaptcha.module
index b28364a..435ac8b 100644
--- a/recaptcha.module
+++ b/recaptcha.module
@@ -98,7 +98,6 @@ function recaptcha_captcha($op, $captcha_type = '') {
 
           $captcha['form']['recaptcha_widget'] = [
             '#markup' => '<div' . new Attribute($attributes) . '></div>',
-            '#suffix' => $noscript,
             '#attached' => [
               'html_head' => [
                 [

Not sure why, but I've not been able to generate a full patch including this variable removal. Sorry about that.