From 6516f7047a34ccfebf9d787b7bdb7c4988e4f9b9 Mon Sep 17 00:00:00 2001 From: 1day2die Date: Wed, 4 Jan 2023 12:04:44 +0100 Subject: [PATCH] recaptcha on password reset --- .../Auth/ForgotPasswordController.php | 29 +++++++++++++++++++ .../views/auth/passwords/email.blade.php | 13 +++++++++ 2 files changed, 42 insertions(+) diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index 465c39cc..01c08be3 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -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', + ]); + } + + + + } } diff --git a/resources/views/auth/passwords/email.blade.php b/resources/views/auth/passwords/email.blade.php index e96d6d36..916ed0c5 100644 --- a/resources/views/auth/passwords/email.blade.php +++ b/resources/views/auth/passwords/email.blade.php @@ -37,13 +37,26 @@ @enderror + @if (config('SETTINGS::RECAPTCHA:ENABLED') == 'true') +
+ {!! htmlFormSnippet() !!} + @error('g-recaptcha-response') + + {{ $message }} + + @enderror +
+ @endif +
+
+

{{ __('Login') }}