mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-11 19:03:46 +02:00
Add handler to fetch all of the system permissions and load them into the state
This commit is contained in:
@@ -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,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user