recaptcha on password reset

This commit is contained in:
1day2die 2023-01-04 12:04:44 +01:00
parent 81662b8e17
commit 6516f7047a
2 changed files with 42 additions and 0 deletions

View file

@ -4,6 +4,8 @@ namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
use Illuminate\Support\Facades\Validator;
use Illuminate\Http\Request;
class ForgotPasswordController extends Controller
{
@ -19,4 +21,31 @@ class ForgotPasswordController extends Controller
*/
use SendsPasswordResetEmails;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
protected function validateEmail(Request $request)
{
$this->validate($request, [
'email' => ['required', 'string', 'email', 'max:255'],
]);
if (config('SETTINGS::RECAPTCHA:ENABLED') == 'true') {
$this->validate($request, [
'g-recaptcha-response' => 'required|recaptcha',
]);
}
}
}

View file

@ -37,13 +37,26 @@
@enderror
</div>
@if (config('SETTINGS::RECAPTCHA:ENABLED') == 'true')
<div class="input-group mb-3">
{!! htmlFormSnippet() !!}
@error('g-recaptcha-response')
<span class="text-danger" role="alert">
<small><strong>{{ $message }}</strong></small>
</span>
@enderror
</div>
@endif
<div class="row">
<div class="col-12">
<button type="submit"
class="btn btn-primary btn-block">{{ __('Request new password') }}</button>
</div>
<!-- /.col -->
</div>
</form>
<p class="mt-3 mb-1">
<a href="{{ route('login') }}">{{ __('Login') }}</a>