|
14 | 14 | use Magento\Framework\Exception\InputException; |
15 | 15 | use Magento\Framework\Exception\LocalizedException; |
16 | 16 | use Magento\Framework\Serialize\SerializerInterface; |
17 | | -use Magento\ReCaptchaUi\Model\IsCaptchaEnabledInterface; |
18 | 17 | use Magento\ReCaptchaUi\Model\CaptchaResponseResolverInterface; |
| 18 | +use Magento\ReCaptchaUi\Model\IsCaptchaEnabledInterface; |
19 | 19 | use Magento\ReCaptchaUi\Model\ValidationConfigResolverInterface; |
20 | 20 | use Magento\ReCaptchaValidationApi\Api\ValidatorInterface; |
21 | 21 | use Psr\Log\LoggerInterface; |
@@ -108,19 +108,15 @@ public function execute(Observer $observer): void |
108 | 108 | try { |
109 | 109 | $reCaptchaResponse = $this->captchaResponseResolver->resolve($request); |
110 | 110 | } catch (InputException $e) { |
| 111 | + $reCaptchaResponse = null; |
111 | 112 | $this->logger->error($e); |
| 113 | + } |
112 | 114 |
|
113 | | - $jsonPayload = $this->serializer->serialize([ |
114 | | - 'success' => false, |
115 | | - 'error' => true, |
116 | | - 'error_messages' => $validationConfig->getValidationFailureMessage(), |
117 | | - ]); |
118 | | - $response->representJson($jsonPayload); |
119 | | - return; |
| 115 | + if (null !== $reCaptchaResponse) { |
| 116 | + $validationResult = $this->captchaValidator->isValid($reCaptchaResponse, $validationConfig); |
120 | 117 | } |
121 | 118 |
|
122 | | - $validationResult = $this->captchaValidator->isValid($reCaptchaResponse, $validationConfig); |
123 | | - if (false === $validationResult->isValid()) { |
| 119 | + if (null === $reCaptchaResponse || false === $validationResult->isValid()) { |
124 | 120 | $this->actionFlag->set('', Action::FLAG_NO_DISPATCH, true); |
125 | 121 |
|
126 | 122 | $jsonPayload = $this->serializer->serialize([ |
|
0 commit comments