feature/MAPG-242-add-captcha-for-signup-and-password-reset #54
@ -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'));
|
$user = $this->userRepository->getByEmail($this->request->post('email'));
|
||||||
|
|
||||||
if ($user === null) {
|
if ($user === null) {
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
@js(https://www.google.com/recaptcha/api.js)
|
||||||
|
|
||||||
@extends(templates/layout_normal)
|
@extends(templates/layout_normal)
|
||||||
|
|
||||||
@section(main)
|
@section(main)
|
||||||
@ -5,6 +7,11 @@
|
|||||||
<div class="box">
|
<div class="box">
|
||||||
<form id="passwordResetForm" action="/password/requestReset" method="post" data-redirect-on-success="/password/requestReset/success">
|
<form id="passwordResetForm" action="/password/requestReset" method="post" data-redirect-on-success="/password/requestReset/success">
|
||||||
<input type="email" class="text big fullWidth" name="email" placeholder="Email address" value="<?= isset($email) ? $email : '' ?>" required autofocus>
|
<input type="email" class="text big fullWidth" name="email" placeholder="Email address" value="<?= isset($email) ? $email : '' ?>" required autofocus>
|
||||||
|
<?php if (!empty($_ENV['RECAPTCHA_SITEKEY'])): ?>
|
||||||
|
<div class="marginTop">
|
||||||
|
<div class="g-recaptcha" data-sitekey="<?= $_ENV['RECAPTCHA_SITEKEY'] ?>"></div>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
<p id="passwordResetFormError" class="formError justify marginTop"></p>
|
<p id="passwordResetFormError" class="formError justify marginTop"></p>
|
||||||
<div class="right marginTop">
|
<div class="right marginTop">
|
||||||
<button type="submit">Continue</button>
|
<button type="submit">Continue</button>
|
||||||
|
Loading…
Reference in New Issue
Block a user