File tree Expand file tree Collapse file tree 1 file changed +4
-12
lines changed
Expand file tree Collapse file tree 1 file changed +4
-12
lines changed Original file line number Diff line number Diff line change @@ -101,23 +101,15 @@ public function hasReadAccess(User $user): bool
101101 return true ;
102102 }
103103
104- public function scopeHasAccess ($ query , User $ user )
104+ public function scopeHasAccess (Builder $ query , User $ user ): Builder
105105 {
106106 if ($ user ->hasGlobalRead ()) {
107107 return $ query ;
108108 }
109109
110- // Allow only if the user has access to all devices on the map
111- return $ query ->withCount ([
112- 'nodes as device_nodes_count ' => function (Builder $ q ): void {
113- $ q ->whereNotNull ('device_id ' );
114- },
115- 'nodes as device_nodes_allowed_count ' => function (Builder $ q ) use ($ user ): void {
116- $ this ->hasDeviceAccess ($ q , $ user , 'custom_map_nodes ' );
117- },
118- ])
119- ->havingRaw ('device_nodes_count = device_nodes_allowed_count ' )
120- ->having ('device_nodes_count ' , '> ' , 0 );
110+ // Only show maps where ALL device nodes are accessible by the user
111+ return $ query ->whereHas ('nodes ' , fn ($ q ) => $ q ->whereNotNull ('device_id ' ))
112+ ->whereDoesntHave ('nodes ' , fn ($ q ) => $ q ->whereNotNull ('device_id ' )->whereNotIn ('device_id ' , \Permissions::devicesForUser ($ user )));
121113 }
122114
123115 /**
You can’t perform that action at this time.
0 commit comments