Skip to content

Commit e4caaaf

Browse files
committed
security-package: Added try/catch to Magento\ReCaptchaUi\Model\RequestHandler.php
1 parent db0456c commit e4caaaf

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

ReCaptchaUi/Model/RequestHandler.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,20 @@ public function execute(
7474
HttpResponseInterface $response,
7575
string $redirectOnFailureUrl
7676
): void {
77-
$reCaptchaResponse = $this->captchaResponseResolver->resolve($request);
78-
$validationConfig = $this->validationConfigResolver->get($key);
7977

80-
$validationResult = $this->captchaValidator->isValid($reCaptchaResponse, $validationConfig);
81-
if (false === $validationResult->isValid()) {
82-
$this->messageManager->addErrorMessage($validationConfig->getValidationFailureMessage());
78+
try {
79+
$reCaptchaResponse = $this->captchaResponseResolver->resolve($request);
80+
$validationConfig = $this->validationConfigResolver->get($key);
81+
82+
$validationResult = $this->captchaValidator->isValid($reCaptchaResponse, $validationConfig);
83+
if (false === $validationResult->isValid()) {
84+
$this->messageManager->addErrorMessage($validationConfig->getValidationFailureMessage());
85+
$this->actionFlag->set('', Action::FLAG_NO_DISPATCH, true);
86+
87+
$response->setRedirect($redirectOnFailureUrl);
88+
}
89+
} catch (\Exception $e) {
90+
$this->messageManager->addErrorMessage($e->getMessage());
8391
$this->actionFlag->set('', Action::FLAG_NO_DISPATCH, true);
8492

8593
$response->setRedirect($redirectOnFailureUrl);

0 commit comments

Comments
 (0)