File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed
ReCaptchaCustomer/Model/AjaxLogin
ReCaptchaValidation/Model Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ public function __construct(SerializerInterface $serializer)
3232 }
3333
3434 /**
35- * @inheritdoc
35+ * { @inheritdoc}
3636 *
3737 * @param RequestInterface|PlainTextRequestInterface $request
3838 * @return string
Original file line number Diff line number Diff line change 1212use Magento \ReCaptchaValidationApi \Api \Data \ValidationConfigInterface ;
1313use Magento \ReCaptchaValidationApi \Api \ValidatorInterface ;
1414use Magento \ReCaptchaValidationApi \Model \ErrorMessagesProvider ;
15+ use ReCaptcha \ReCaptcha ;
1516use ReCaptcha \ReCaptchaFactory ;
1617
1718/**
@@ -56,21 +57,22 @@ public function isValid(
5657 string $ reCaptchaResponse ,
5758 ValidationConfigInterface $ validationConfig
5859 ): ValidationResult {
59- $ secret = $ validationConfig ->getPrivateKey ();
60- $ reCaptcha = $ this ->reCaptchaFactory ->create (['secret ' => $ secret ]);
60+ /** @var ReCaptcha $reCaptcha */
61+ $ reCaptcha = $ this ->reCaptchaFactory ->create (['secret ' => $ validationConfig ->getPrivateKey ()]);
62+
6163 $ extensionAttributes = $ validationConfig ->getExtensionAttributes ();
6264 if ($ extensionAttributes && (null !== $ extensionAttributes ->getScoreThreshold ())) {
6365 $ reCaptcha ->setScoreThreshold ($ extensionAttributes ->getScoreThreshold ());
6466 }
67+
6568 $ result = $ reCaptcha ->verify ($ reCaptchaResponse , $ validationConfig ->getRemoteIp ());
6669
6770 $ validationErrors = [];
68- if (! $ result ->isSuccess ()) {
71+ if (false === $ result ->isSuccess ()) {
6972 foreach ($ result ->getErrorCodes () as $ errorCode ) {
7073 $ validationErrors [] = $ this ->errorMessagesProvider ->getErrorMessage ($ errorCode );
7174 }
7275 }
73-
7476 return $ this ->validationResultFactory ->create (['errors ' => $ validationErrors ]);
7577 }
7678}
You can’t perform that action at this time.
0 commit comments