MAPG-242 add captcha validation for password reset
mapguesser/pipeline/pr-develop This commit looks good

This commit is contained in:
bence committed 2022-05-26 18:45:16 +02:00
1 parent 241d2f2b30
commit cc19d454fa
2 files changed
+19

No files matched your search

+12
View File
@@ -468,6 +468,18 @@ class LoginController
]);
}
if (!empty($_ENV['RECAPTCHA_SITEKEY'])) {
if (!$this->request->post('g-recaptcha-response')) {
return new JsonContent(['error' => ['errorText' => 'Please check "I\'m not a robot" in the reCAPTCHA box!']]);
}
$captchaValidator = new CaptchaValidator();
$captchaResponse = $captchaValidator->validate($this->request->post('g-recaptcha-response'));
if (!$captchaResponse['success']) {
return new JsonContent(['error' => ['errorText' => 'reCAPTCHA challenge failed. Please try again!']]);
}
}
$user = $this->userRepository->getByEmail($this->request->post('email'));
if ($user === null) {