chg: pkg: make compatible the whole project with bare metal AND with docker #4
This commit is contained in:
@@ -42,6 +42,11 @@ 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.
|
||||
if ($token === '') {
|
||||
$token = (string) ($event->getData() ?? '');
|
||||
}
|
||||
$event->setData($token);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -58,6 +58,14 @@ readonly class RecaptchaService
|
||||
->request('POST', self::SITEVERIFY_URL, ['body' => $body])
|
||||
->toArray();
|
||||
|
||||
$this->logger->info('reCAPTCHA verify response', [
|
||||
'success' => $data['success'] ?? null,
|
||||
'score' => $data['score'] ?? null,
|
||||
'hostname' => $data['hostname'] ?? null,
|
||||
'error-codes' => $data['error-codes'] ?? [],
|
||||
'token_length' => strlen($token),
|
||||
]);
|
||||
|
||||
return ($data['success'] ?? false) === true
|
||||
&& ($data['score'] ?? 0.0) >= self::SCORE_THRESHOLD;
|
||||
} catch (\Throwable $e) {
|
||||
|
||||
Reference in New Issue
Block a user