Extend webform handler to support reCAPTCHA v3, updated hadler should allow to:
- Select reCAPTCHA type per webform ( v2 checkbox / v3 invisible )
- select desired reCAPTCHA v3 score limit
- allow to set error message, which will be shown to visitors, when reCAPTCHA token verification fails
- add action name to recaptcha verification requests ( most likely webform name )

Comments

sandboxpl created an issue. See original summary.

  • sandboxpl committed afc1690 on 8.x-1.x
    Issue #3066210 by sandboxpl: Add reCAPTCHA v3 support to webforms
    
sandboxpl’s picture

This is now possible, webform handler allows to choose two types of reCAPTCHA:
- v2 (checkbox)
- v3 (invisible)
Additional settings for v3 protections are:
- desired reCAPTCHA score - this allows to choose score between 0 and 100 , any reCAPTCHA validation score lower than configured value will be recognized as spam and block form submission
- Custom error message - This error message will be shown when reCAPTCHA validation will fail.

New release with notes and documentation updates will be provided soon

sandboxpl’s picture

sandboxpl’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

renguer0’s picture

Hi. I can't add recaptcha handler on handler webform's page. The others handlers works but recaptcha didn't show anything.

There is a know issue?

sandboxpl’s picture

Hey @renguer0 ,
I'm not aware of any issues with missing webform handlers,
everything should be available after enabling simple_recaptcha_webform submodule,
if you have module enabled and you can't find handlers in webform settings please provide YAML export of your webform,
so I can check what's going on

renguer0’s picture

Hello @sandboxpl ! Thanks for your answer.

I see recaptcha webform handler in webform settings (of course I have the three modules enabled too) but when I click in add, nothing happens.

Maybe I can enable debugging or something else for see what's going wrong? I'm in lastest stable version of Drupal and dev version of modules.

sandboxpl’s picture

It sounds like some error is being thrown during AJAX submission of webform settings,
please check your browser's console, you will probably see some errors there,
you can also turn on dblog module and check /admin/reports/dblog page, you should find some useful debug information there.

I'm trying to reproduce the issue with core 8.7.7 locally, but I can't see anything so far,
can you navigate to /admin/structure/webform/manage/YOUR_WEBFORM_ID/source and provide YAML source generated on that page ?

renguer0’s picture

Of course! I disabled Advagg and see this error message when tried to enable the handler:

The website encountered an unexpected error. Please try again later.
TypeError: Argument 3 passed to Drupal\simple_recaptcha\SimpleReCaptchaFormManager::__construct() must be an instance of Drupal\Core\Logger\LoggerChannelFactory, instance of Drupal\redirect_404\Render\Redirect404LogSuppressor given, called in /home/MYSITE/public_html/core/lib/Drupal/Component/DependencyInjection/Container.php on line 277 in Drupal\simple_recaptcha\SimpleReCaptchaFormManager->__construct() (line 49 of modules/simple_recaptcha/src/SimpleReCaptchaFormManager.php).

This is the yaml source:

message:
  '#type': textarea
  '#title': Mensaje
  '#autocomplete': 'off'
  '#required': true
  '#test': 'Dudas, comentarios, sugerencias?'
recibir_copia_:
  '#type': checkbox
  '#title': 'Recibir copia?'
  '#help_title': Ayuda
  '#help': 'Seleccioná esta casilla si querés recibir una copia de tu formulario en tu e-mail'
  '#required': true
e_mail:
  '#type': email
  '#title': E-Mail
  '#help_title': Ayuda
  '#help': 'Tipeá una dirección válida, de lo contrario no podremos responderte'
  '#autocomplete': 'off'
  '#required': true
actions:
  '#type': webform_actions
  '#title': 'Submit button(s)'
  '#submit__label': 'Enviar mensaje'
sandboxpl’s picture

@renguer0 that's a really nice catch !
Logger service should be injected by interface to avoid conflicts like this, I've pushed a fix for that:
https://git.drupalcode.org/project/simple_recaptcha/commit/53630688529d5...

Please update to recent dev version , the error should be gone now

renguer0’s picture

Thanks for your reply @sandboxpl. I updated the module and checked the modifications were applied on the file via FTP. Now I see this error when I try to add the handler:

The website encountered an unexpected error. Please try again later.
TypeError: Argument 3 passed to Drupal\simple_recaptcha\SimpleReCaptchaFormManager::__construct() must be an instance of Drupal\Core\Logger\LoggerChannelFactory, instance of Drupal\redirect_404\Render\Redirect404LogSuppressor given, called in /home/MYSITE/public_html/core/lib/Drupal/Component/DependencyInjection/Container.php on line 277 in Drupal\simple_recaptcha\SimpleReCaptchaFormManager->__construct() (line 52 of modules/simple_recaptcha/src/SimpleReCaptchaFormManager.php).

Hope it can be fix soon. ReCaptcha is really a must.