Fixes #4056 - check for assets before deleting user

This commit is contained in:
snipe 2017-09-28 19:57:52 -07:00
parent 507f1f196c
commit 51236a2ad9

View file

@ -376,6 +376,11 @@ class UsersController extends Controller
return redirect()->route('users.index')->with('error', 'This user still has ' . $user->assets()->count() . ' assets associated with them.'); return redirect()->route('users.index')->with('error', 'This user still has ' . $user->assets()->count() . ' assets associated with them.');
} }
if (count($user->assets) > 0) {
// Redirect to the user management page
return redirect()->route('users.index')->with('error', 'This user still has ' . count($user->assets) . ' assets associated with them.');
}
if ($user->licenses()->count() > 0) { if ($user->licenses()->count() > 0) {
// Redirect to the user management page // Redirect to the user management page
return redirect()->route('users.index')->with('error', 'This user still has ' . $user->assets()->count() . ' assets associated with them.'); return redirect()->route('users.index')->with('error', 'This user still has ' . $user->assets()->count() . ' assets associated with them.');