Private
Public Access
chg: usr: replace Google ReCaptcha with Cap instance #13
This commit is contained in:
@@ -22,8 +22,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
/**
|
||||
* Class RecaptchaType
|
||||
*
|
||||
* Reads the Google reCAPTCHA v3 token from the raw POST field
|
||||
* `g-recaptcha-response` (populated by JS before form submit) and injects
|
||||
* Reads the Cap CAPTCHA token from the raw POST field
|
||||
* `cap-token` (auto-injected by the cap-widget web component) and injects
|
||||
* it as this field's value before validation runs.
|
||||
*
|
||||
* @package App\Form
|
||||
@@ -41,9 +41,8 @@ class RecaptchaType extends AbstractType
|
||||
{
|
||||
$builder->addEventListener(FormEvents::PRE_SUBMIT, function (PreSubmitEvent $event): void {
|
||||
$request = $this->requestStack->getCurrentRequest();
|
||||
$token = $request?->request->getString('g-recaptcha-response') ?? '';
|
||||
// For forms that set the token directly on the field (e.g. registration_form[recaptcha])
|
||||
// rather than via a standalone g-recaptcha-response input, fall back to the submitted value.
|
||||
$token = $request?->request->getString('cap-token') ?? '';
|
||||
// For forms that set the token directly on the field, fall back to the submitted value.
|
||||
if ($token === '') {
|
||||
$token = (string) ($event->getData() ?? '');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user