Skip to content

Commit 463f465

Browse files
committed
Block viewing node allocations and location unless user has permission
Blocks viewing the allocation list and location for a node unless a user has permission to view the node in the first place.
1 parent 4479d3b commit 463f465

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

app/Transformers/Admin/NodeTransformer.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ public function transform(Node $node)
8080
*/
8181
public function includeAllocations(Node $node)
8282
{
83+
if ($this->request && ! $this->request->apiKeyHasPermission('view-node')) {
84+
return;
85+
}
86+
8387
return $this->collection($node->allocations, new AllocationTransformer, 'allocation');
8488
}
8589

@@ -90,6 +94,10 @@ public function includeAllocations(Node $node)
9094
*/
9195
public function includeLocation(Node $node)
9296
{
97+
if ($this->request && ! $this->request->apiKeyHasPermission('view-node')) {
98+
return;
99+
}
100+
93101
return $this->item($node->location, new LocationTransformer, 'location');
94102
}
95103

0 commit comments

Comments
 (0)