Skip to content

A free open source IT asset/license management system

Fixes #4056 - check for assets before deleting user

snipe9b6726a63082
diff --git a/app/Http/Controllers/UsersController.php b/app/Http/Controllers/UsersController.php
index 62360ff51c..31f3741445 100755
--- a/app/Http/Controllers/UsersController.php
+++ b/app/Http/Controllers/UsersController.php
@@ -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.');
}
+ 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) {
// Redirect to the user management page
return redirect()->route('users.index')->with('error', 'This user still has ' . $user->assets()->count() . ' assets associated with them.');