A free open source IT asset/license management system
Set empty array if permissions are null
snipe66b2cc2e28bd
diff --git a/app/Models/User.php b/app/Models/User.phpindex 793f073ccd..bd03367d1a 100644--- a/app/Models/User.php+++ b/app/Models/User.php@@ -744,10 +744,20 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCopublic function decodePermissions(){- $permissions = json_decode($this->permissions, JSON_OBJECT_AS_ARRAY);+ // Set default to empty JSON if the value is null+ $permissions = json_decode($this->permissions ?? '{}', JSON_OBJECT_AS_ARRAY);++ // If there are no permissions, return an empty array+ if (!$permissions) {+ return [];+ }++ // Otherwise, loop through the permissions and cast the values as integersforeach ($permissions as $permission => $value) {$permissions[$permission] = (int) $value;}++return $permissions;}