Skip to content

A free open source IT asset/license management system

Use saveQuietly to prevent double entries

snipeba127be34423
diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php
index d67d673a21..f3900eff25 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);