A free open source IT asset/license management system
Fixed missing password.token string and checked for user existing before trying to reset
snipe21875100b655
diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.phpindex 95700e2992..99c1580c10 100644--- a/app/Http/Controllers/Auth/ResetPasswordController.php+++ b/app/Http/Controllers/Auth/ResetPasswordController.php@@ -73,6 +73,7 @@ class ResetPasswordController extends Controllerpublic function reset(Request $request){+$messages = ['password.not_in' => trans('validation.disallow_same_pwd_as_user_fields'),];@@ -80,27 +81,36 @@ class ResetPasswordController extends Controller$request->validate($this->rules(), $request->all(), $this->validationErrorMessages());// Check to see if the user even exists- $user = User::where('username', '=', $request->input('username'))->first();-- $broker = $this->broker();- if (strpos(Setting::passwordComplexityRulesSaving('store'), 'disallow_same_pwd_as_user_fields') !== false) {- $request->validate(- [- 'password' => 'required|notIn:["'.$user->email.'","'.$user->username.'","'.$user->first_name.'","'.$user->last_name.'"',- ], $messages);- }+ if ($user = User::where('username', '=', $request->input('username'))->first()) {+ $broker = $this->broker();++ if (strpos(Setting::passwordComplexityRulesSaving('store'), 'disallow_same_pwd_as_user_fields') !== false) {+ $request->validate(+ [+ 'password' => 'required|notIn:["'.$user->email.'","'.$user->username.'","'.$user->first_name.'","'.$user->last_name.'"',+ ], $messages);+ }- $response = $broker->reset(- $this->credentials($request), function ($user, $password) {+ $response = $broker->reset(+ $this->credentials($request), function ($user, $password) {$this->resetPassword($user, $password);});- return $response == \Password::PASSWORD_RESET- ? $this->sendResetResponse($request, $response)- : $this->sendResetFailedResponse($request, $response);+ return $response == \Password::PASSWORD_RESET+ ? $this->sendResetResponse($request, $response)+ : $this->sendResetFailedResponse($request, $response);+ }++ // the user doesn't exist, so we're not really sending anything here+ return redirect()->route('login')+ ->withInput(['username'=> $request->input('username')])+ ->with('success', trans('passwords.sent'));+}++protected function sendResetFailedResponse(Request $request, $response){return redirect()->back()diff --git a/resources/lang/en/passwords.php b/resources/lang/en/passwords.phpindex 4772940015..3491f37b70 100644--- a/resources/lang/en/passwords.php+++ b/resources/lang/en/passwords.php@@ -1,6 +1,7 @@<?phpreturn [- 'sent' => 'Success: If that email address exists in our system, a password recovery email has been sent.',+ 'sent' => 'If that email address exists in our system, a password recovery email has been sent.','user' => 'No matching active user found with that email.',+ "token" => "This password reset token is invalid or expired.",];diff --git a/resources/lang/en/reminders.php b/resources/lang/en/reminders.phpindex e7a476e3a2..0ca927a445 100644--- a/resources/lang/en/reminders.php+++ b/resources/lang/en/reminders.php@@ -17,7 +17,7 @@ return array("user" => "Username or email address is incorrect",- "token" => "This password reset token is invalid.",+ "token" => "This password reset token is invalid or expired.","sent" => "If a matching email address was found, a password reminder has been sent!",