From ba127be34423493893eaa8514bb454f2755627a7 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 22 Nov 2023 23:00:30 +0000 Subject: [PATCH] Use saveQuietly to prevent double entries Signed-off-by: snipe --- app/Http/Controllers/ProfileController.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index d67d673a2..f3900eff2 100755 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -134,6 +134,7 @@ class ProfileController extends Controller ]; $validator = \Validator::make($request->all(), $rules); + $validator->after(function ($validator) use ($request, $user) { if (! Hash::check($request->input('current_password'), $user->password)) { $validator->errors()->add('current_password', trans('validation.custom.hashed_pass')); @@ -159,12 +160,14 @@ class ProfileController extends Controller }); if (! $validator->fails()) { - $user->password = Hash::make($request->input('password')); - $user->save(); + $user->password = Hash::make($request->input('password')); + // We have to use saveQuietly here because for some reason this method was calling the User Oserver twice :( + $user->saveQuietly(); + // Log the user out of other devices Auth::logoutOtherDevices($request->input('password')); - return redirect()->route('account.password.index')->with('success', 'Password updated!'); + return redirect()->route('account')->with('success', trans('passwords.password_change')); } return redirect()->back()->withInput()->withErrors($validator);