File tree Expand file tree Collapse file tree
Classes/Domain/Repository Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -41,13 +41,26 @@ public function __construct(
4141
4242 public function findAllByCurrentUser (int |null $ limit = null ): array |null
4343 {
44- $ userGroups = array_keys ($ GLOBALS ['BE_USER ' ]->userGroups );
44+ // Validate backend user exists and is authenticated
45+ if (!isset ($ GLOBALS ['BE_USER ' ]) || !is_object ($ GLOBALS ['BE_USER ' ])) {
46+ return [];
47+ }
48+
49+ $ backendUser = $ GLOBALS ['BE_USER ' ];
50+
51+ // Validate user groups property exists and is an array
52+ if (!property_exists ($ backendUser , 'userGroups ' ) || !is_array ($ backendUser ->userGroups )) {
53+ return [];
54+ }
55+
56+ $ userGroups = array_keys ($ backendUser ->userGroups );
4557 $ cacheIdentifier = $ this ->cache ->generateCacheIdentifier ($ userGroups );
4658 if ($ this ->cache ->has ($ cacheIdentifier )) {
4759 return $ this ->cache ->get ($ cacheIdentifier );
4860 }
4961
50- if ($ GLOBALS ['BE_USER ' ]->isAdmin ()) {
62+ // Check if user has admin privileges
63+ if (method_exists ($ backendUser , 'isAdmin ' ) && $ backendUser ->isAdmin ()) {
5164 $ result = $ this ->findAll ()->toArray ();
5265 $ this ->cache ->set ($ cacheIdentifier , $ result );
5366 return $ result ;
You can’t perform that action at this time.
0 commit comments