From 405545cd8834d985ce79b4c543c01336bdfdfee2 Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Thu, 29 Jul 2021 16:02:45 -0500 Subject: [PATCH] Add exception handling in the ForgotPasswordController --- .../Auth/ForgotPasswordController.php | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index d54ca4ed09..d97afcb396 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -61,7 +61,7 @@ class ForgotPasswordController extends Controller $request->validate([ 'username' => ['required', 'max:255'], ]); - + /** @@ -71,13 +71,21 @@ class ForgotPasswordController extends Controller * Once we have attempted to send the link, we will examine the response * then see the message we need to show to the user. Finally, we'll send out a proper response. */ - $response = $this->broker()->sendResetLink( - array_merge( - $request->only('username'), - ['activated' => '1'], - ['ldap_import' => '0'] - ) - ); + + $response = null; + + try { + $response = $this->broker()->sendResetLink( + array_merge( + $request->only('username'), + ['activated' => '1'], + ['ldap_import' => '0'] + ) + ); + } catch(\Exception $e) { + \Log::info('Password reset attempt: User '.$request->input('username').' doesnt have email setted' ); + } + if ($response === \Password::RESET_LINK_SENT) { \Log::info('Password reset attempt: User '.$request->input('username').' WAS found, password reset sent');