api(application): fix requests
This commit is contained in:
parent
409c081275
commit
5737b5dc5d
54 changed files with 88 additions and 556 deletions
|
@ -7,6 +7,7 @@ use Webmozart\Assert\Assert;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Container\Container;
|
use Illuminate\Container\Container;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
use Pterodactyl\Http\Controllers\Controller;
|
use Pterodactyl\Http\Controllers\Controller;
|
||||||
use Pterodactyl\Extensions\Spatie\Fractalistic\Fractal;
|
use Pterodactyl\Extensions\Spatie\Fractalistic\Fractal;
|
||||||
use Pterodactyl\Transformers\Api\Application\BaseTransformer;
|
use Pterodactyl\Transformers\Api\Application\BaseTransformer;
|
||||||
|
@ -45,9 +46,6 @@ abstract class ApplicationApiController extends Controller
|
||||||
/**
|
/**
|
||||||
* Perform dependency injection of certain classes needed for core functionality
|
* Perform dependency injection of certain classes needed for core functionality
|
||||||
* without littering the constructors of classes that extend this abstract.
|
* without littering the constructors of classes that extend this abstract.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Extensions\Spatie\Fractalistic\Fractal $fractal
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
*/
|
*/
|
||||||
public function loadDependencies(Fractal $fractal, Request $request)
|
public function loadDependencies(Fractal $fractal, Request $request)
|
||||||
{
|
{
|
||||||
|
@ -58,17 +56,18 @@ abstract class ApplicationApiController extends Controller
|
||||||
/**
|
/**
|
||||||
* Return an instance of an application transformer.
|
* Return an instance of an application transformer.
|
||||||
*
|
*
|
||||||
* @param string $abstract
|
|
||||||
*
|
|
||||||
* @return \Pterodactyl\Transformers\Api\Application\BaseTransformer
|
* @return \Pterodactyl\Transformers\Api\Application\BaseTransformer
|
||||||
|
*
|
||||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function getTransformer(string $abstract)
|
public function getTransformer(string $abstract)
|
||||||
{
|
{
|
||||||
/** @var \Pterodactyl\Transformers\Api\Application\BaseTransformer $transformer */
|
/** @var \Pterodactyl\Transformers\Api\Application\BaseTransformer $transformer */
|
||||||
$transformer = Container::getInstance()->make($abstract);
|
$transformer = Container::getInstance()->make($abstract);
|
||||||
$transformer->setRootAdmin($this->request->user()->root_admin);
|
|
||||||
|
$apiKey = $this->request->attributes->get('api_key');
|
||||||
$transformer->setKey($this->request->attributes->get('api_key'));
|
$transformer->setKey($this->request->attributes->get('api_key'));
|
||||||
|
$transformer->setRootAdmin($this->request->user()->root_admin);
|
||||||
|
|
||||||
Assert::isInstanceOf($transformer, BaseTransformer::class);
|
Assert::isInstanceOf($transformer, BaseTransformer::class);
|
||||||
|
|
||||||
|
@ -77,8 +76,6 @@ abstract class ApplicationApiController extends Controller
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a HTTP/204 response for the API.
|
* Return a HTTP/204 response for the API.
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\Response
|
|
||||||
*/
|
*/
|
||||||
protected function returnNoContent(): Response
|
protected function returnNoContent(): Response
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,20 +16,9 @@ use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||||
|
|
||||||
class AuthenticateKey
|
class AuthenticateKey
|
||||||
{
|
{
|
||||||
/**
|
private AuthManager $auth;
|
||||||
* @var \Illuminate\Auth\AuthManager
|
private Encrypter $encrypter;
|
||||||
*/
|
private ApiKeyRepositoryInterface $repository;
|
||||||
private $auth;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \Illuminate\Contracts\Encryption\Encrypter
|
|
||||||
*/
|
|
||||||
private $encrypter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface
|
|
||||||
*/
|
|
||||||
private $repository;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AuthenticateKey constructor.
|
* AuthenticateKey constructor.
|
||||||
|
|
|
@ -9,15 +9,8 @@ use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||||
|
|
||||||
class DeleteAllocationRequest extends ApplicationApiRequest
|
class DeleteAllocationRequest extends ApplicationApiRequest
|
||||||
{
|
{
|
||||||
/**
|
protected string $resource = AdminAcl::RESOURCE_ALLOCATIONS;
|
||||||
* @var string
|
protected int $permission = AdminAcl::WRITE;
|
||||||
*/
|
|
||||||
protected $resource = AdminAcl::RESOURCE_ALLOCATIONS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $permission = AdminAcl::WRITE;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if the requested allocation exists and belongs to the node that
|
* Determine if the requested allocation exists and belongs to the node that
|
||||||
|
|
|
@ -8,15 +8,8 @@ use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||||
|
|
||||||
class GetAllocationsRequest extends ApplicationApiRequest
|
class GetAllocationsRequest extends ApplicationApiRequest
|
||||||
{
|
{
|
||||||
/**
|
protected string $resource = AdminAcl::RESOURCE_ALLOCATIONS;
|
||||||
* @var string
|
protected int $permission = AdminAcl::READ;
|
||||||
*/
|
|
||||||
protected $resource = AdminAcl::RESOURCE_ALLOCATIONS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $permission = AdminAcl::READ;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if the node that we are requesting the allocations
|
* Determine if the node that we are requesting the allocations
|
||||||
|
|
|
@ -7,15 +7,8 @@ use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||||
|
|
||||||
class StoreAllocationRequest extends ApplicationApiRequest
|
class StoreAllocationRequest extends ApplicationApiRequest
|
||||||
{
|
{
|
||||||
/**
|
protected string $resource = AdminAcl::RESOURCE_ALLOCATIONS;
|
||||||
* @var string
|
protected int $permission = AdminAcl::WRITE;
|
||||||
*/
|
|
||||||
protected $resource = AdminAcl::RESOURCE_ALLOCATIONS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $permission = AdminAcl::WRITE;
|
|
||||||
|
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
|
@ -27,10 +20,7 @@ class StoreAllocationRequest extends ApplicationApiRequest
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function validated(): array
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function validated()
|
|
||||||
{
|
{
|
||||||
$data = parent::validated();
|
$data = parent::validated();
|
||||||
|
|
||||||
|
|
|
@ -15,10 +15,8 @@ abstract class ApplicationApiRequest extends FormRequest
|
||||||
/**
|
/**
|
||||||
* Tracks if the request has been validated internally or not to avoid
|
* Tracks if the request has been validated internally or not to avoid
|
||||||
* making duplicate validation calls.
|
* making duplicate validation calls.
|
||||||
*
|
|
||||||
* @var bool
|
|
||||||
*/
|
*/
|
||||||
private $hasValidated = false;
|
private bool $hasValidated = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The resource that should be checked when performing the authorization
|
* The resource that should be checked when performing the authorization
|
||||||
|
@ -26,7 +24,7 @@ abstract class ApplicationApiRequest extends FormRequest
|
||||||
*
|
*
|
||||||
* @var string|null
|
* @var string|null
|
||||||
*/
|
*/
|
||||||
protected $resource;
|
protected string $resource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The permission level that a given API key should have for accessing
|
* The permission level that a given API key should have for accessing
|
||||||
|
@ -34,7 +32,7 @@ abstract class ApplicationApiRequest extends FormRequest
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
protected $permission = AdminAcl::NONE;
|
protected int $permission = AdminAcl::NONE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if the current user is authorized to perform
|
* Determine if the current user is authorized to perform
|
||||||
|
@ -48,7 +46,7 @@ abstract class ApplicationApiRequest extends FormRequest
|
||||||
throw new PterodactylException('An ACL resource must be defined on API requests.');
|
throw new PterodactylException('An ACL resource must be defined on API requests.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! is_null($this->user())) {
|
if ($this->key()->key_type === ApiKey::TYPE_ACCOUNT) {
|
||||||
return $this->user()->root_admin;
|
return $this->user()->root_admin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,23 +7,9 @@ use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||||
|
|
||||||
class DatabaseNodesRequest extends ApplicationApiRequest
|
class DatabaseNodesRequest extends ApplicationApiRequest
|
||||||
{
|
{
|
||||||
/**
|
protected string $resource = AdminAcl::RESOURCE_DATABASE_HOSTS;
|
||||||
* @var string
|
protected int $permission = AdminAcl::WRITE;
|
||||||
*/
|
|
||||||
protected $resource = AdminAcl::RESOURCE_DATABASE_HOSTS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $permission = AdminAcl::WRITE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ?
|
|
||||||
*
|
|
||||||
* @param array|null $rules
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function rules(array $rules = null): array
|
public function rules(array $rules = null): array
|
||||||
{
|
{
|
||||||
return $rules ?? ['nodes' => 'required|exists:nodes,id'];
|
return $rules ?? ['nodes' => 'required|exists:nodes,id'];
|
||||||
|
|
|
@ -8,21 +8,9 @@ use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||||
|
|
||||||
class DeleteDatabaseRequest extends ApplicationApiRequest
|
class DeleteDatabaseRequest extends ApplicationApiRequest
|
||||||
{
|
{
|
||||||
/**
|
protected string $resource = AdminAcl::RESOURCE_DATABASE_HOSTS;
|
||||||
* @var string
|
protected int $permission = AdminAcl::WRITE;
|
||||||
*/
|
|
||||||
protected $resource = AdminAcl::RESOURCE_DATABASE_HOSTS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $permission = AdminAcl::WRITE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine if the requested database exists on the Panel.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function resourceExists(): bool
|
public function resourceExists(): bool
|
||||||
{
|
{
|
||||||
$databaseHost = $this->route()->parameter('databaseHost');
|
$databaseHost = $this->route()->parameter('databaseHost');
|
||||||
|
|
|
@ -6,11 +6,6 @@ use Pterodactyl\Models\DatabaseHost;
|
||||||
|
|
||||||
class GetDatabaseRequest extends GetDatabasesRequest
|
class GetDatabaseRequest extends GetDatabasesRequest
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Determine if the requested database exists on the Panel.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function resourceExists(): bool
|
public function resourceExists(): bool
|
||||||
{
|
{
|
||||||
$databaseHost = $this->route()->parameter('databaseHost');
|
$databaseHost = $this->route()->parameter('databaseHost');
|
||||||
|
|
|
@ -7,13 +7,6 @@ use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||||
|
|
||||||
class GetDatabasesRequest extends ApplicationApiRequest
|
class GetDatabasesRequest extends ApplicationApiRequest
|
||||||
{
|
{
|
||||||
/**
|
protected string $resource = Acl::RESOURCE_DATABASE_HOSTS;
|
||||||
* @var string
|
protected int $permission = Acl::READ;
|
||||||
*/
|
|
||||||
protected $resource = Acl::RESOURCE_DATABASE_HOSTS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $permission = Acl::READ;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,23 +8,9 @@ use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||||
|
|
||||||
class StoreDatabaseRequest extends ApplicationApiRequest
|
class StoreDatabaseRequest extends ApplicationApiRequest
|
||||||
{
|
{
|
||||||
/**
|
protected string $resource = AdminAcl::RESOURCE_DATABASE_HOSTS;
|
||||||
* @var string
|
protected int $permission = AdminAcl::WRITE;
|
||||||
*/
|
|
||||||
protected $resource = AdminAcl::RESOURCE_DATABASE_HOSTS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $permission = AdminAcl::WRITE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ?
|
|
||||||
*
|
|
||||||
* @param array|null $rules
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function rules(array $rules = null): array
|
public function rules(array $rules = null): array
|
||||||
{
|
{
|
||||||
return $rules ?? DatabaseHost::getRules();
|
return $rules ?? DatabaseHost::getRules();
|
||||||
|
|
|
@ -6,13 +6,6 @@ use Pterodactyl\Models\DatabaseHost;
|
||||||
|
|
||||||
class UpdateDatabaseRequest extends StoreDatabaseRequest
|
class UpdateDatabaseRequest extends StoreDatabaseRequest
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* ?
|
|
||||||
*
|
|
||||||
* @param array|null $rules
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function rules(array $rules = null): array
|
public function rules(array $rules = null): array
|
||||||
{
|
{
|
||||||
return $rules ?? DatabaseHost::getRulesForUpdate($this->route()->parameter('databaseHost')->id);
|
return $rules ?? DatabaseHost::getRulesForUpdate($this->route()->parameter('databaseHost')->id);
|
||||||
|
|
|
@ -8,19 +8,9 @@ use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||||
|
|
||||||
class DeleteEggRequest extends ApplicationApiRequest
|
class DeleteEggRequest extends ApplicationApiRequest
|
||||||
{
|
{
|
||||||
/**
|
protected string $resource = AdminAcl::RESOURCE_EGGS;
|
||||||
* @var string
|
protected int $permission = AdminAcl::WRITE;
|
||||||
*/
|
|
||||||
protected $resource = AdminAcl::RESOURCE_EGGS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $permission = AdminAcl::WRITE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine if the requested egg exists for the selected nest.
|
|
||||||
*/
|
|
||||||
public function resourceExists(): bool
|
public function resourceExists(): bool
|
||||||
{
|
{
|
||||||
$egg = $this->route()->parameter('egg');
|
$egg = $this->route()->parameter('egg');
|
||||||
|
|
|
@ -6,11 +6,6 @@ use Pterodactyl\Models\Egg;
|
||||||
|
|
||||||
class GetEggRequest extends GetEggsRequest
|
class GetEggRequest extends GetEggsRequest
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Determine if the requested egg exists on the Panel.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function resourceExists(): bool
|
public function resourceExists(): bool
|
||||||
{
|
{
|
||||||
$egg = $this->route()->parameter('egg');
|
$egg = $this->route()->parameter('egg');
|
||||||
|
|
|
@ -7,13 +7,6 @@ use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||||
|
|
||||||
class GetEggsRequest extends ApplicationApiRequest
|
class GetEggsRequest extends ApplicationApiRequest
|
||||||
{
|
{
|
||||||
/**
|
protected string $resource = AdminAcl::RESOURCE_EGGS;
|
||||||
* @var string
|
protected int $permission = AdminAcl::READ;
|
||||||
*/
|
|
||||||
protected $resource = AdminAcl::RESOURCE_EGGS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $permission = AdminAcl::READ;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,23 +8,9 @@ use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||||
|
|
||||||
class StoreEggRequest extends ApplicationApiRequest
|
class StoreEggRequest extends ApplicationApiRequest
|
||||||
{
|
{
|
||||||
/**
|
protected string $resource = AdminAcl::RESOURCE_EGGS;
|
||||||
* @var string
|
protected int $permission = AdminAcl::WRITE;
|
||||||
*/
|
|
||||||
protected $resource = AdminAcl::RESOURCE_EGGS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $permission = AdminAcl::WRITE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ?
|
|
||||||
*
|
|
||||||
* @param array|null $rules
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function rules(array $rules = null): array
|
public function rules(array $rules = null): array
|
||||||
{
|
{
|
||||||
return $rules ?? Egg::getRules();
|
return $rules ?? Egg::getRules();
|
||||||
|
|
|
@ -6,13 +6,6 @@ use Pterodactyl\Models\Egg;
|
||||||
|
|
||||||
class UpdateEggRequest extends StoreEggRequest
|
class UpdateEggRequest extends StoreEggRequest
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* ?
|
|
||||||
*
|
|
||||||
* @param array|null $rules
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function rules(array $rules = null): array
|
public function rules(array $rules = null): array
|
||||||
{
|
{
|
||||||
return $rules ?? Egg::getRulesForUpdate($this->route()->parameter('egg')->id);
|
return $rules ?? Egg::getRulesForUpdate($this->route()->parameter('egg')->id);
|
||||||
|
|
|
@ -8,19 +8,9 @@ use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||||
|
|
||||||
class DeleteLocationRequest extends ApplicationApiRequest
|
class DeleteLocationRequest extends ApplicationApiRequest
|
||||||
{
|
{
|
||||||
/**
|
protected string $resource = AdminAcl::RESOURCE_LOCATIONS;
|
||||||
* @var string
|
protected int $permission = AdminAcl::WRITE;
|
||||||
*/
|
|
||||||
protected $resource = AdminAcl::RESOURCE_LOCATIONS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $permission = AdminAcl::WRITE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine if the requested location exists on the Panel.
|
|
||||||
*/
|
|
||||||
public function resourceExists(): bool
|
public function resourceExists(): bool
|
||||||
{
|
{
|
||||||
$location = $this->route()->parameter('location');
|
$location = $this->route()->parameter('location');
|
||||||
|
|
|
@ -6,9 +6,6 @@ use Pterodactyl\Models\Location;
|
||||||
|
|
||||||
class GetLocationRequest extends GetLocationsRequest
|
class GetLocationRequest extends GetLocationsRequest
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Determine if the requested location exists on the Panel.
|
|
||||||
*/
|
|
||||||
public function resourceExists(): bool
|
public function resourceExists(): bool
|
||||||
{
|
{
|
||||||
$location = $this->route()->parameter('location');
|
$location = $this->route()->parameter('location');
|
||||||
|
|
|
@ -7,13 +7,6 @@ use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||||
|
|
||||||
class GetLocationsRequest extends ApplicationApiRequest
|
class GetLocationsRequest extends ApplicationApiRequest
|
||||||
{
|
{
|
||||||
/**
|
protected string $resource = AdminAcl::RESOURCE_LOCATIONS;
|
||||||
* @var string
|
protected int $permission = AdminAcl::READ;
|
||||||
*/
|
|
||||||
protected $resource = AdminAcl::RESOURCE_LOCATIONS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $permission = AdminAcl::READ;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,19 +8,9 @@ use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||||
|
|
||||||
class StoreLocationRequest extends ApplicationApiRequest
|
class StoreLocationRequest extends ApplicationApiRequest
|
||||||
{
|
{
|
||||||
/**
|
protected string $resource = AdminAcl::RESOURCE_LOCATIONS;
|
||||||
* @var string
|
protected int $permission = AdminAcl::WRITE;
|
||||||
*/
|
|
||||||
protected $resource = AdminAcl::RESOURCE_LOCATIONS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $permission = AdminAcl::WRITE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rules to validate the request against.
|
|
||||||
*/
|
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
return collect(Location::getRules())->only([
|
return collect(Location::getRules())->only([
|
||||||
|
@ -29,12 +19,7 @@ class StoreLocationRequest extends ApplicationApiRequest
|
||||||
])->toArray();
|
])->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function attributes(): array
|
||||||
* Rename fields to be more clear in error messages.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function attributes()
|
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'long' => 'Location Description',
|
'long' => 'Location Description',
|
||||||
|
|
|
@ -6,9 +6,6 @@ use Pterodactyl\Models\Location;
|
||||||
|
|
||||||
class UpdateLocationRequest extends StoreLocationRequest
|
class UpdateLocationRequest extends StoreLocationRequest
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Determine if the requested location exists on the Panel.
|
|
||||||
*/
|
|
||||||
public function resourceExists(): bool
|
public function resourceExists(): bool
|
||||||
{
|
{
|
||||||
$location = $this->route()->parameter('location');
|
$location = $this->route()->parameter('location');
|
||||||
|
@ -16,9 +13,6 @@ class UpdateLocationRequest extends StoreLocationRequest
|
||||||
return $location instanceof Location && $location->exists;
|
return $location instanceof Location && $location->exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Rules to validate this request against.
|
|
||||||
*/
|
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
$locationId = $this->route()->parameter('location')->id;
|
$locationId = $this->route()->parameter('location')->id;
|
||||||
|
|
|
@ -8,21 +8,9 @@ use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||||
|
|
||||||
class DeleteMountRequest extends ApplicationApiRequest
|
class DeleteMountRequest extends ApplicationApiRequest
|
||||||
{
|
{
|
||||||
/**
|
protected string $resource = AdminAcl::RESOURCE_MOUNTS;
|
||||||
* @var string
|
protected int $permission = AdminAcl::WRITE;
|
||||||
*/
|
|
||||||
protected $resource = AdminAcl::RESOURCE_MOUNTS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $permission = AdminAcl::WRITE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine if the requested mount exists on the Panel.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function resourceExists(): bool
|
public function resourceExists(): bool
|
||||||
{
|
{
|
||||||
$mount = $this->route()->parameter('mount');
|
$mount = $this->route()->parameter('mount');
|
||||||
|
|
|
@ -6,11 +6,6 @@ use Pterodactyl\Models\Mount;
|
||||||
|
|
||||||
class GetMountRequest extends GetMountsRequest
|
class GetMountRequest extends GetMountsRequest
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Determine if the requested mount exists on the Panel.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function resourceExists(): bool
|
public function resourceExists(): bool
|
||||||
{
|
{
|
||||||
$mount = $this->route()->parameter('mount');
|
$mount = $this->route()->parameter('mount');
|
||||||
|
|
|
@ -7,13 +7,6 @@ use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||||
|
|
||||||
class GetMountsRequest extends ApplicationApiRequest
|
class GetMountsRequest extends ApplicationApiRequest
|
||||||
{
|
{
|
||||||
/**
|
protected string $resource = Acl::RESOURCE_MOUNTS;
|
||||||
* @var string
|
protected int $permission = Acl::READ;
|
||||||
*/
|
|
||||||
protected $resource = Acl::RESOURCE_MOUNTS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $permission = Acl::READ;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,23 +7,9 @@ use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||||
|
|
||||||
class MountEggsRequest extends ApplicationApiRequest
|
class MountEggsRequest extends ApplicationApiRequest
|
||||||
{
|
{
|
||||||
/**
|
protected string $resource = AdminAcl::RESOURCE_MOUNTS;
|
||||||
* @var string
|
protected int $permission = AdminAcl::WRITE;
|
||||||
*/
|
|
||||||
protected $resource = AdminAcl::RESOURCE_MOUNTS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $permission = AdminAcl::WRITE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ?
|
|
||||||
*
|
|
||||||
* @param array|null $rules
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function rules(array $rules = null): array
|
public function rules(array $rules = null): array
|
||||||
{
|
{
|
||||||
return $rules ?? ['eggs' => 'required|exists:eggs,id'];
|
return $rules ?? ['eggs' => 'required|exists:eggs,id'];
|
||||||
|
|
|
@ -7,23 +7,9 @@ use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||||
|
|
||||||
class MountNodesRequest extends ApplicationApiRequest
|
class MountNodesRequest extends ApplicationApiRequest
|
||||||
{
|
{
|
||||||
/**
|
protected string $resource = AdminAcl::RESOURCE_MOUNTS;
|
||||||
* @var string
|
protected int $permission = AdminAcl::WRITE;
|
||||||
*/
|
|
||||||
protected $resource = AdminAcl::RESOURCE_MOUNTS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $permission = AdminAcl::WRITE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ?
|
|
||||||
*
|
|
||||||
* @param array|null $rules
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function rules(array $rules = null): array
|
public function rules(array $rules = null): array
|
||||||
{
|
{
|
||||||
return $rules ?? ['nodes' => 'required|exists:nodes,id'];
|
return $rules ?? ['nodes' => 'required|exists:nodes,id'];
|
||||||
|
|
|
@ -8,23 +8,9 @@ use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||||
|
|
||||||
class StoreMountRequest extends ApplicationApiRequest
|
class StoreMountRequest extends ApplicationApiRequest
|
||||||
{
|
{
|
||||||
/**
|
protected string $resource = AdminAcl::RESOURCE_MOUNTS;
|
||||||
* @var string
|
protected int $permission = AdminAcl::WRITE;
|
||||||
*/
|
|
||||||
protected $resource = AdminAcl::RESOURCE_MOUNTS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $permission = AdminAcl::WRITE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ?
|
|
||||||
*
|
|
||||||
* @param array|null $rules
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function rules(array $rules = null): array
|
public function rules(array $rules = null): array
|
||||||
{
|
{
|
||||||
return $rules ?? Mount::getRules();
|
return $rules ?? Mount::getRules();
|
||||||
|
|
|
@ -6,13 +6,6 @@ use Pterodactyl\Models\Mount;
|
||||||
|
|
||||||
class UpdateMountRequest extends StoreMountRequest
|
class UpdateMountRequest extends StoreMountRequest
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* ?
|
|
||||||
*
|
|
||||||
* @param array|null $rules
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function rules(array $rules = null): array
|
public function rules(array $rules = null): array
|
||||||
{
|
{
|
||||||
return $rules ?? Mount::getRulesForUpdate($this->route()->parameter('mount')->id);
|
return $rules ?? Mount::getRulesForUpdate($this->route()->parameter('mount')->id);
|
||||||
|
|
|
@ -8,21 +8,9 @@ use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||||
|
|
||||||
class DeleteNestRequest extends ApplicationApiRequest
|
class DeleteNestRequest extends ApplicationApiRequest
|
||||||
{
|
{
|
||||||
/**
|
protected string $resource = AdminAcl::RESOURCE_NESTS;
|
||||||
* @var string
|
protected int $permission = AdminAcl::WRITE;
|
||||||
*/
|
|
||||||
protected $resource = AdminAcl::RESOURCE_NESTS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $permission = AdminAcl::WRITE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine if the requested nest exists on the Panel.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function resourceExists(): bool
|
public function resourceExists(): bool
|
||||||
{
|
{
|
||||||
$nest = $this->route()->parameter('nest');
|
$nest = $this->route()->parameter('nest');
|
||||||
|
|
|
@ -6,11 +6,6 @@ use Pterodactyl\Models\Nest;
|
||||||
|
|
||||||
class GetNestRequest extends GetNestsRequest
|
class GetNestRequest extends GetNestsRequest
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Determine if the requested nest exists on the Panel.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function resourceExists(): bool
|
public function resourceExists(): bool
|
||||||
{
|
{
|
||||||
$nest = $this->route()->parameter('nest');
|
$nest = $this->route()->parameter('nest');
|
||||||
|
|
|
@ -7,13 +7,6 @@ use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||||
|
|
||||||
class GetNestsRequest extends ApplicationApiRequest
|
class GetNestsRequest extends ApplicationApiRequest
|
||||||
{
|
{
|
||||||
/**
|
protected string $resource = AdminAcl::RESOURCE_NESTS;
|
||||||
* @var string
|
protected int $permission = AdminAcl::READ;
|
||||||
*/
|
|
||||||
protected $resource = AdminAcl::RESOURCE_NESTS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $permission = AdminAcl::READ;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,23 +8,9 @@ use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||||
|
|
||||||
class StoreNestRequest extends ApplicationApiRequest
|
class StoreNestRequest extends ApplicationApiRequest
|
||||||
{
|
{
|
||||||
/**
|
protected string $resource = AdminAcl::RESOURCE_NESTS;
|
||||||
* @var string
|
protected int $permission = AdminAcl::WRITE;
|
||||||
*/
|
|
||||||
protected $resource = AdminAcl::RESOURCE_NESTS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $permission = AdminAcl::WRITE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ?
|
|
||||||
*
|
|
||||||
* @param array|null $rules
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function rules(array $rules = null): array
|
public function rules(array $rules = null): array
|
||||||
{
|
{
|
||||||
return $rules ?? Nest::getRules();
|
return $rules ?? Nest::getRules();
|
||||||
|
|
|
@ -6,13 +6,6 @@ use Pterodactyl\Models\Nest;
|
||||||
|
|
||||||
class UpdateNestRequest extends StoreNestRequest
|
class UpdateNestRequest extends StoreNestRequest
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* ?
|
|
||||||
*
|
|
||||||
* @param array|null $rules
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function rules(array $rules = null): array
|
public function rules(array $rules = null): array
|
||||||
{
|
{
|
||||||
return $rules ?? Nest::getRulesForUpdate($this->route()->parameter('nest')->id);
|
return $rules ?? Nest::getRulesForUpdate($this->route()->parameter('nest')->id);
|
||||||
|
|
|
@ -8,20 +8,9 @@ use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||||
|
|
||||||
class DeleteNodeRequest extends ApplicationApiRequest
|
class DeleteNodeRequest extends ApplicationApiRequest
|
||||||
{
|
{
|
||||||
/**
|
protected string $resource = AdminAcl::RESOURCE_NODES;
|
||||||
* @var string
|
protected int $permission = AdminAcl::WRITE;
|
||||||
*/
|
|
||||||
protected $resource = AdminAcl::RESOURCE_NODES;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $permission = AdminAcl::WRITE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine if the node being requested for editing exists
|
|
||||||
* on the Panel before validating the data.
|
|
||||||
*/
|
|
||||||
public function resourceExists(): bool
|
public function resourceExists(): bool
|
||||||
{
|
{
|
||||||
$node = $this->route()->parameter('node');
|
$node = $this->route()->parameter('node');
|
||||||
|
|
|
@ -4,9 +4,6 @@ namespace Pterodactyl\Http\Requests\Api\Application\Nodes;
|
||||||
|
|
||||||
class GetDeployableNodesRequest extends GetNodesRequest
|
class GetDeployableNodesRequest extends GetNodesRequest
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @return string[]
|
|
||||||
*/
|
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|
|
@ -6,9 +6,6 @@ use Pterodactyl\Models\Node;
|
||||||
|
|
||||||
class GetNodeRequest extends GetNodesRequest
|
class GetNodeRequest extends GetNodesRequest
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Determine if the requested node exists on the Panel.
|
|
||||||
*/
|
|
||||||
public function resourceExists(): bool
|
public function resourceExists(): bool
|
||||||
{
|
{
|
||||||
$node = $this->route()->parameter('node');
|
$node = $this->route()->parameter('node');
|
||||||
|
|
|
@ -7,13 +7,6 @@ use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||||
|
|
||||||
class GetNodesRequest extends ApplicationApiRequest
|
class GetNodesRequest extends ApplicationApiRequest
|
||||||
{
|
{
|
||||||
/**
|
protected string $resource = AdminAcl::RESOURCE_NODES;
|
||||||
* @var string
|
protected int $permission = AdminAcl::READ;
|
||||||
*/
|
|
||||||
protected $resource = AdminAcl::RESOURCE_NODES;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $permission = AdminAcl::READ;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,15 +8,8 @@ use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||||
|
|
||||||
class StoreNodeRequest extends ApplicationApiRequest
|
class StoreNodeRequest extends ApplicationApiRequest
|
||||||
{
|
{
|
||||||
/**
|
protected string $resource = AdminAcl::RESOURCE_NODES;
|
||||||
* @var string
|
protected int $permission = AdminAcl::WRITE;
|
||||||
*/
|
|
||||||
protected $resource = AdminAcl::RESOURCE_NODES;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $permission = AdminAcl::WRITE;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validation rules to apply to this request.
|
* Validation rules to apply to this request.
|
||||||
|
|
|
@ -6,14 +6,8 @@ use Pterodactyl\Models\Node;
|
||||||
|
|
||||||
class UpdateNodeRequest extends StoreNodeRequest
|
class UpdateNodeRequest extends StoreNodeRequest
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Apply validation rules to this request. Uses the parent class rules()
|
|
||||||
* function but passes in the rules for updating rather than creating.
|
|
||||||
*/
|
|
||||||
public function rules(array $rules = null): array
|
public function rules(array $rules = null): array
|
||||||
{
|
{
|
||||||
$nodeId = $this->getModel(Node::class)->id;
|
return parent::rules($rules ?? Node::getRulesForUpdate($this->route()->parameter('node')->id));
|
||||||
|
|
||||||
return parent::rules(Node::getRulesForUpdate($nodeId));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,21 +8,9 @@ use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||||
|
|
||||||
class DeleteRoleRequest extends ApplicationApiRequest
|
class DeleteRoleRequest extends ApplicationApiRequest
|
||||||
{
|
{
|
||||||
/**
|
protected string $resource = AdminAcl::RESOURCE_ROLES;
|
||||||
* @var string
|
protected int $permission = AdminAcl::WRITE;
|
||||||
*/
|
|
||||||
protected $resource = AdminAcl::RESOURCE_ROLES;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $permission = AdminAcl::WRITE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine if the requested role exists on the Panel.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function resourceExists(): bool
|
public function resourceExists(): bool
|
||||||
{
|
{
|
||||||
$role = $this->route()->parameter('role');
|
$role = $this->route()->parameter('role');
|
||||||
|
|
|
@ -6,11 +6,6 @@ use Pterodactyl\Models\AdminRole;
|
||||||
|
|
||||||
class GetRoleRequest extends GetRolesRequest
|
class GetRoleRequest extends GetRolesRequest
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Determine if the requested role exists on the Panel.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function resourceExists(): bool
|
public function resourceExists(): bool
|
||||||
{
|
{
|
||||||
$role = $this->route()->parameter('role');
|
$role = $this->route()->parameter('role');
|
||||||
|
|
|
@ -7,13 +7,6 @@ use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||||
|
|
||||||
class GetRolesRequest extends ApplicationApiRequest
|
class GetRolesRequest extends ApplicationApiRequest
|
||||||
{
|
{
|
||||||
/**
|
protected string $resource = Acl::RESOURCE_ROLES;
|
||||||
* @var string
|
protected int $permission = Acl::READ;
|
||||||
*/
|
|
||||||
protected $resource = Acl::RESOURCE_ROLES;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $permission = Acl::READ;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,23 +8,9 @@ use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||||
|
|
||||||
class StoreRoleRequest extends ApplicationApiRequest
|
class StoreRoleRequest extends ApplicationApiRequest
|
||||||
{
|
{
|
||||||
/**
|
protected string $resource = AdminAcl::RESOURCE_ROLES;
|
||||||
* @var string
|
protected int $permission = AdminAcl::WRITE;
|
||||||
*/
|
|
||||||
protected $resource = AdminAcl::RESOURCE_ROLES;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $permission = AdminAcl::WRITE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ?
|
|
||||||
*
|
|
||||||
* @param array|null $rules
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function rules(array $rules = null): array
|
public function rules(array $rules = null): array
|
||||||
{
|
{
|
||||||
return $rules ?? AdminRole::getRules();
|
return $rules ?? AdminRole::getRules();
|
||||||
|
|
|
@ -6,13 +6,6 @@ use Pterodactyl\Models\AdminRole;
|
||||||
|
|
||||||
class UpdateRoleRequest extends StoreRoleRequest
|
class UpdateRoleRequest extends StoreRoleRequest
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* ?
|
|
||||||
*
|
|
||||||
* @param array|null $rules
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function rules(array $rules = null): array
|
public function rules(array $rules = null): array
|
||||||
{
|
{
|
||||||
return $rules ?? AdminRole::getRulesForUpdate($this->route()->parameter('role')->id);
|
return $rules ?? AdminRole::getRulesForUpdate($this->route()->parameter('role')->id);
|
||||||
|
|
|
@ -8,19 +8,9 @@ use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||||
|
|
||||||
class DeleteUserRequest extends ApplicationApiRequest
|
class DeleteUserRequest extends ApplicationApiRequest
|
||||||
{
|
{
|
||||||
/**
|
protected string $resource = AdminAcl::RESOURCE_USERS;
|
||||||
* @var string
|
protected int $permission = AdminAcl::WRITE;
|
||||||
*/
|
|
||||||
protected $resource = AdminAcl::RESOURCE_USERS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $permission = AdminAcl::WRITE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine if the requested user exists on the Panel.
|
|
||||||
*/
|
|
||||||
public function resourceExists(): bool
|
public function resourceExists(): bool
|
||||||
{
|
{
|
||||||
$user = $this->route()->parameter('user');
|
$user = $this->route()->parameter('user');
|
||||||
|
|
|
@ -10,24 +10,10 @@ use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||||
|
|
||||||
class GetExternalUserRequest extends ApplicationApiRequest
|
class GetExternalUserRequest extends ApplicationApiRequest
|
||||||
{
|
{
|
||||||
/**
|
private User $userModel;
|
||||||
* @var User
|
protected string $resource = AdminAcl::RESOURCE_USERS;
|
||||||
*/
|
protected int $permission = AdminAcl::READ;
|
||||||
private $userModel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $resource = AdminAcl::RESOURCE_USERS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $permission = AdminAcl::READ;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine if the requested external user exists.
|
|
||||||
*/
|
|
||||||
public function resourceExists(): bool
|
public function resourceExists(): bool
|
||||||
{
|
{
|
||||||
$repository = $this->container->make(UserRepositoryInterface::class);
|
$repository = $this->container->make(UserRepositoryInterface::class);
|
||||||
|
@ -43,9 +29,6 @@ class GetExternalUserRequest extends ApplicationApiRequest
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the user model for the requested external user.
|
|
||||||
*/
|
|
||||||
public function getUserModel(): User
|
public function getUserModel(): User
|
||||||
{
|
{
|
||||||
return $this->userModel;
|
return $this->userModel;
|
||||||
|
|
|
@ -6,11 +6,6 @@ use Pterodactyl\Models\User;
|
||||||
|
|
||||||
class GetUserRequest extends GetUsersRequest
|
class GetUserRequest extends GetUsersRequest
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Determine if the requested role exists on the Panel.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function resourceExists(): bool
|
public function resourceExists(): bool
|
||||||
{
|
{
|
||||||
$user = $this->route()->parameter('user');
|
$user = $this->route()->parameter('user');
|
||||||
|
|
|
@ -7,13 +7,6 @@ use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||||
|
|
||||||
class GetUsersRequest extends ApplicationApiRequest
|
class GetUsersRequest extends ApplicationApiRequest
|
||||||
{
|
{
|
||||||
/**
|
protected string $resource = Acl::RESOURCE_USERS;
|
||||||
* @var string
|
protected int $permission = Acl::READ;
|
||||||
*/
|
|
||||||
protected $resource = Acl::RESOURCE_USERS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $permission = Acl::READ;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,19 +8,9 @@ use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||||
|
|
||||||
class StoreUserRequest extends ApplicationApiRequest
|
class StoreUserRequest extends ApplicationApiRequest
|
||||||
{
|
{
|
||||||
/**
|
protected string $resource = AdminAcl::RESOURCE_USERS;
|
||||||
* @var string
|
protected int $permission = AdminAcl::WRITE;
|
||||||
*/
|
|
||||||
protected $resource = AdminAcl::RESOURCE_USERS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $permission = AdminAcl::WRITE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the validation rules for this request.
|
|
||||||
*/
|
|
||||||
public function rules(array $rules = null): array
|
public function rules(array $rules = null): array
|
||||||
{
|
{
|
||||||
$rules = $rules ?? User::getRules();
|
$rules = $rules ?? User::getRules();
|
||||||
|
@ -40,10 +30,7 @@ class StoreUserRequest extends ApplicationApiRequest
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function validated(): array
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function validated()
|
|
||||||
{
|
{
|
||||||
$data = parent::validated();
|
$data = parent::validated();
|
||||||
|
|
||||||
|
@ -55,12 +42,7 @@ class StoreUserRequest extends ApplicationApiRequest
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function attributes(): array
|
||||||
* Rename some fields to be more user friendly.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function attributes()
|
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'external_id' => 'Third Party Identifier',
|
'external_id' => 'Third Party Identifier',
|
||||||
|
|
|
@ -6,13 +6,8 @@ use Pterodactyl\Models\User;
|
||||||
|
|
||||||
class UpdateUserRequest extends StoreUserRequest
|
class UpdateUserRequest extends StoreUserRequest
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Return the validation rules for this request.
|
|
||||||
*/
|
|
||||||
public function rules(array $rules = null): array
|
public function rules(array $rules = null): array
|
||||||
{
|
{
|
||||||
$userId = $this->getModel(User::class)->id;
|
return parent::rules($rules ?? User::getRulesForUpdate($this->route()->parameter('user')->id));
|
||||||
|
|
||||||
return parent::rules(User::getRulesForUpdate($userId));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,20 +17,12 @@ abstract class BaseTransformer extends TransformerAbstract
|
||||||
{
|
{
|
||||||
public const RESPONSE_TIMEZONE = 'UTC';
|
public const RESPONSE_TIMEZONE = 'UTC';
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \Pterodactyl\Models\ApiKey
|
|
||||||
*/
|
|
||||||
private ApiKey $key;
|
private ApiKey $key;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
private bool $rootAdmin;
|
private bool $rootAdmin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the resource name for the JSONAPI output.
|
* Return the resource name for the JSONAPI output.
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
abstract public function getResourceName(): string;
|
abstract public function getResourceName(): string;
|
||||||
|
|
||||||
|
@ -48,8 +40,6 @@ abstract class BaseTransformer extends TransformerAbstract
|
||||||
/**
|
/**
|
||||||
* Set the HTTP request class being used for this request.
|
* Set the HTTP request class being used for this request.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\ApiKey $key
|
|
||||||
*
|
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setKey(ApiKey $key)
|
public function setKey(ApiKey $key)
|
||||||
|
@ -61,8 +51,6 @@ abstract class BaseTransformer extends TransformerAbstract
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the request instance being used for this transformer.
|
* Return the request instance being used for this transformer.
|
||||||
*
|
|
||||||
* @return \Pterodactyl\Models\ApiKey
|
|
||||||
*/
|
*/
|
||||||
public function getKey(): ApiKey
|
public function getKey(): ApiKey
|
||||||
{
|
{
|
||||||
|
@ -72,8 +60,6 @@ abstract class BaseTransformer extends TransformerAbstract
|
||||||
/**
|
/**
|
||||||
* ?
|
* ?
|
||||||
*
|
*
|
||||||
* @param bool $rootAdmin
|
|
||||||
*
|
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setRootAdmin(bool $rootAdmin)
|
public function setRootAdmin(bool $rootAdmin)
|
||||||
|
@ -85,8 +71,6 @@ abstract class BaseTransformer extends TransformerAbstract
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ?
|
* ?
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
public function isRootAdmin(): bool
|
public function isRootAdmin(): bool
|
||||||
{
|
{
|
||||||
|
@ -97,10 +81,6 @@ abstract class BaseTransformer extends TransformerAbstract
|
||||||
* Determine if the API key loaded onto the transformer has permission
|
* Determine if the API key loaded onto the transformer has permission
|
||||||
* to access a different resource. This is used when including other
|
* to access a different resource. This is used when including other
|
||||||
* models on a transformation request.
|
* models on a transformation request.
|
||||||
*
|
|
||||||
* @param string $resource
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
protected function authorize(string $resource): bool
|
protected function authorize(string $resource): bool
|
||||||
{
|
{
|
||||||
|
@ -115,9 +95,6 @@ abstract class BaseTransformer extends TransformerAbstract
|
||||||
* Create a new instance of the transformer and pass along the currently
|
* Create a new instance of the transformer and pass along the currently
|
||||||
* set API key.
|
* set API key.
|
||||||
*
|
*
|
||||||
* @param string $abstract
|
|
||||||
* @param array $parameters
|
|
||||||
*
|
|
||||||
* @return \Pterodactyl\Transformers\Api\Application\BaseTransformer
|
* @return \Pterodactyl\Transformers\Api\Application\BaseTransformer
|
||||||
*
|
*
|
||||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
|
@ -138,10 +115,6 @@ abstract class BaseTransformer extends TransformerAbstract
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an ISO-8601 formatted timestamp to use in the API response.
|
* Return an ISO-8601 formatted timestamp to use in the API response.
|
||||||
*
|
|
||||||
* @param string $timestamp
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
protected function formatTimestamp(string $timestamp): string
|
protected function formatTimestamp(string $timestamp): string
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,6 +41,7 @@ class LocationTransformer extends BaseTransformer
|
||||||
*
|
*
|
||||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||||
*
|
*
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||||
*/
|
*/
|
||||||
public function includeServers(Location $location)
|
public function includeServers(Location $location)
|
||||||
|
@ -59,7 +60,9 @@ class LocationTransformer extends BaseTransformer
|
||||||
*
|
*
|
||||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||||
*
|
*
|
||||||
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||||
|
|
||||||
*/
|
*/
|
||||||
public function includeNodes(Location $location)
|
public function includeNodes(Location $location)
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,7 +27,7 @@ class LocationControllerTest extends ApplicationApiIntegrationTestCase
|
||||||
['object', 'attributes' => ['id', 'short', 'long', 'created_at', 'updated_at']],
|
['object', 'attributes' => ['id', 'short', 'long', 'created_at', 'updated_at']],
|
||||||
['object', 'attributes' => ['id', 'short', 'long', 'created_at', 'updated_at']],
|
['object', 'attributes' => ['id', 'short', 'long', 'created_at', 'updated_at']],
|
||||||
],
|
],
|
||||||
'meta' => ['pagination' => ['total', 'count', 'per_page', 'current_page', 'total_pages']],
|
'meta' => ['pagination' => ['total', 'count', 'per_page', 'current_page', 'total_pages', 'links']],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response
|
$response
|
||||||
|
@ -38,9 +38,10 @@ class LocationControllerTest extends ApplicationApiIntegrationTestCase
|
||||||
'pagination' => [
|
'pagination' => [
|
||||||
'total' => 2,
|
'total' => 2,
|
||||||
'count' => 2,
|
'count' => 2,
|
||||||
'per_page' => 100,
|
'per_page' => 10,
|
||||||
'current_page' => 1,
|
'current_page' => 1,
|
||||||
'total_pages' => 1,
|
'total_pages' => 1,
|
||||||
|
'links' => [],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
])
|
])
|
||||||
|
|
Loading…
Reference in a new issue