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.
This commit is contained in:
Dane Everitt 2017-04-08 12:07:17 -04:00
parent 4479d3bf19
commit 463f465dea
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53

View file

@ -80,6 +80,10 @@ class NodeTransformer extends TransformerAbstract
*/ */
public function includeAllocations(Node $node) public function includeAllocations(Node $node)
{ {
if ($this->request && ! $this->request->apiKeyHasPermission('view-node')) {
return;
}
return $this->collection($node->allocations, new AllocationTransformer, 'allocation'); return $this->collection($node->allocations, new AllocationTransformer, 'allocation');
} }
@ -90,6 +94,10 @@ class NodeTransformer extends TransformerAbstract
*/ */
public function includeLocation(Node $node) public function includeLocation(Node $node)
{ {
if ($this->request && ! $this->request->apiKeyHasPermission('view-node')) {
return;
}
return $this->item($node->location, new LocationTransformer, 'location'); return $this->item($node->location, new LocationTransformer, 'location');
} }