Use saveQuietly to prevent double entries

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2023-11-22 23:00:30 +00:00
parent c6178bd619
commit ba127be344

View file

@ -134,6 +134,7 @@ class ProfileController extends Controller
]; ];
$validator = \Validator::make($request->all(), $rules); $validator = \Validator::make($request->all(), $rules);
$validator->after(function ($validator) use ($request, $user) { $validator->after(function ($validator) use ($request, $user) {
if (! Hash::check($request->input('current_password'), $user->password)) { if (! Hash::check($request->input('current_password'), $user->password)) {
$validator->errors()->add('current_password', trans('validation.custom.hashed_pass')); $validator->errors()->add('current_password', trans('validation.custom.hashed_pass'));
@ -159,12 +160,14 @@ class ProfileController extends Controller
}); });
if (! $validator->fails()) { if (! $validator->fails()) {
$user->password = Hash::make($request->input('password')); $user->password = Hash::make($request->input('password'));
$user->save(); // 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 // Log the user out of other devices
Auth::logoutOtherDevices($request->input('password')); 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); return redirect()->back()->withInput()->withErrors($validator);