diff --git a/src/Controller/LoginController.php b/src/Controller/LoginController.php index 3857f0e..52e30a1 100644 --- a/src/Controller/LoginController.php +++ b/src/Controller/LoginController.php @@ -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) { diff --git a/views/login/password_reset_request.php b/views/login/password_reset_request.php index 22d5fe5..8f7c32b 100644 --- a/views/login/password_reset_request.php +++ b/views/login/password_reset_request.php @@ -1,3 +1,5 @@ +@js(https://www.google.com/recaptcha/api.js) + @extends(templates/layout_normal) @section(main) @@ -5,6 +7,11 @@
+ +
+
+
+