diff --git a/ReCaptchaCustomer/Model/AjaxLogin/CaptchaResponseResolver.php b/ReCaptchaCustomer/Model/AjaxLogin/CaptchaResponseResolver.php index 46d62bf7..dacd2c8f 100644 --- a/ReCaptchaCustomer/Model/AjaxLogin/CaptchaResponseResolver.php +++ b/ReCaptchaCustomer/Model/AjaxLogin/CaptchaResponseResolver.php @@ -32,7 +32,7 @@ public function __construct(SerializerInterface $serializer) } /** - * @inheritdoc + * {@inheritdoc} * * @param RequestInterface|PlainTextRequestInterface $request * @return string diff --git a/ReCaptchaValidation/Model/Validator.php b/ReCaptchaValidation/Model/Validator.php index e508fbbf..4508938c 100644 --- a/ReCaptchaValidation/Model/Validator.php +++ b/ReCaptchaValidation/Model/Validator.php @@ -12,6 +12,7 @@ use Magento\ReCaptchaValidationApi\Api\Data\ValidationConfigInterface; use Magento\ReCaptchaValidationApi\Api\ValidatorInterface; use Magento\ReCaptchaValidationApi\Model\ErrorMessagesProvider; +use ReCaptcha\ReCaptcha; use ReCaptcha\ReCaptchaFactory; /** @@ -56,21 +57,22 @@ public function isValid( string $reCaptchaResponse, ValidationConfigInterface $validationConfig ): ValidationResult { - $secret = $validationConfig->getPrivateKey(); - $reCaptcha = $this->reCaptchaFactory->create(['secret' => $secret]); + /** @var ReCaptcha $reCaptcha */ + $reCaptcha = $this->reCaptchaFactory->create(['secret' => $validationConfig->getPrivateKey()]); + $extensionAttributes = $validationConfig->getExtensionAttributes(); if ($extensionAttributes && (null !== $extensionAttributes->getScoreThreshold())) { $reCaptcha->setScoreThreshold($extensionAttributes->getScoreThreshold()); } + $result = $reCaptcha->verify($reCaptchaResponse, $validationConfig->getRemoteIp()); $validationErrors = []; - if (!$result->isSuccess()) { + if (false === $result->isSuccess()) { foreach ($result->getErrorCodes() as $errorCode) { $validationErrors[] = $this->errorMessagesProvider->getErrorMessage($errorCode); } } - return $this->validationResultFactory->create(['errors' => $validationErrors]); } }