Add handler to fetch all of the system permissions and load them into the state

This commit is contained in:
Dane Everitt 2019-11-03 17:37:06 -08:00
parent 867dbf3bd2
commit d69f816d9d
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
8 changed files with 106 additions and 6 deletions

View file

@ -3,6 +3,8 @@
namespace Pterodactyl\Http\Controllers\Api\Client;
use Pterodactyl\Models\User;
use Illuminate\Support\Collection;
use Pterodactyl\Models\Permission;
use Pterodactyl\Repositories\Eloquent\ServerRepository;
use Pterodactyl\Transformers\Api\Client\ServerTransformer;
use Pterodactyl\Http\Requests\Api\Client\GetServersRequest;
@ -62,4 +64,25 @@ class ClientController extends ClientApiController
->transformWith($this->getTransformer(ServerTransformer::class))
->toArray();
}
/**
* Returns all of the subuser permissions available on the system.
*
* @return array
*/
public function permissions()
{
$permissions = Permission::permissions()->map(function ($values, $key) {
return Collection::make($values)->map(function ($permission) use ($key) {
return $key . '.' . $permission;
})->values()->toArray();
})->flatten();
return [
'object' => 'system_permissions',
'attributes' => [
'permissions' => $permissions,
],
];
}
}