mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-19 06:43:45 +02:00
Node and user API routes implemented.
More attempts at the logic for API permissions, most likely will need continued tweaking in the future, but base is there.
This commit is contained in:
@@ -30,6 +30,16 @@ use League\Fractal\TransformerAbstract;
|
||||
|
||||
class UserTransformer extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* List of resources that can be included.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $availableIncludes = [
|
||||
'access',
|
||||
'servers',
|
||||
];
|
||||
|
||||
/**
|
||||
* The Illuminate Request object if provided.
|
||||
*
|
||||
@@ -61,4 +71,32 @@ class UserTransformer extends TransformerAbstract
|
||||
{
|
||||
return $user->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the servers associated with this user.
|
||||
*
|
||||
* @return \Leauge\Fractal\Resource\Collection
|
||||
*/
|
||||
public function includeServers(User $user)
|
||||
{
|
||||
if ($this->request && ! $this->request->apiKeyHasPermission('user-view')) {
|
||||
return;
|
||||
}
|
||||
|
||||
return $this->collection($user->servers, new ServerTransformer($this->request), 'server');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the servers that this user can access.
|
||||
*
|
||||
* @return \Leauge\Fractal\Resource\Collection
|
||||
*/
|
||||
public function includeAccess(User $user)
|
||||
{
|
||||
if ($this->request && ! $this->request->apiKeyHasPermission('user-view')) {
|
||||
return;
|
||||
}
|
||||
|
||||
return $this->collection($user->access()->get(), new ServerTransformer($this->request), 'server');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user