Merge branch 'develop' into dane/restore-backups
This commit is contained in:
commit
663143de0b
575 changed files with 6080 additions and 6864 deletions
|
@ -32,7 +32,6 @@ abstract class AdminFormRequest extends FormRequest
|
|||
* Return only the fields that we are interested in from the request.
|
||||
* This will include empty fields as a null value.
|
||||
*
|
||||
* @param array|null $only
|
||||
* @return array
|
||||
*/
|
||||
public function normalize(array $only = null)
|
||||
|
|
|
@ -10,6 +10,7 @@ class StoreApplicationApiKeyRequest extends AdminFormRequest
|
|||
{
|
||||
/**
|
||||
* @return array
|
||||
*
|
||||
* @throws \ReflectionException
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
|
|
|
@ -25,7 +25,7 @@ class DatabaseHostFormRequest extends AdminFormRequest
|
|||
*/
|
||||
protected function getValidatorInstance()
|
||||
{
|
||||
if (! $this->filled('node_id')) {
|
||||
if (!$this->filled('node_id')) {
|
||||
$this->merge(['node_id' => null]);
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ class EggFormRequest extends AdminFormRequest
|
|||
public function withValidator($validator)
|
||||
{
|
||||
$validator->sometimes('config_from', 'exists:eggs,id', function () {
|
||||
return (int)$this->input('config_from') !== 0;
|
||||
return (int) $this->input('config_from') !== 0;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ class NodeFormRequest extends AdminFormRequest
|
|||
{
|
||||
$validator->after(function ($validator) {
|
||||
// Check that the FQDN is a valid IP address.
|
||||
if (! filter_var(gethostbyname($this->input('fqdn')), FILTER_VALIDATE_IP)) {
|
||||
if (!filter_var(gethostbyname($this->input('fqdn')), FILTER_VALIDATE_IP)) {
|
||||
$validator->errors()->add('fqdn', trans('admin/node.validation.fqdn_not_resolvable'));
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ class ServerFormRequest extends AdminFormRequest
|
|||
{
|
||||
$validator->after(function ($validator) {
|
||||
$validator->sometimes('node_id', 'required|numeric|bail|exists:nodes,id', function ($input) {
|
||||
return ! ($input->auto_deploy);
|
||||
return !($input->auto_deploy);
|
||||
});
|
||||
|
||||
$validator->sometimes('allocation_id', [
|
||||
|
@ -42,7 +42,7 @@ class ServerFormRequest extends AdminFormRequest
|
|||
$query->whereNull('server_id');
|
||||
}),
|
||||
], function ($input) {
|
||||
return ! ($input->auto_deploy);
|
||||
return !($input->auto_deploy);
|
||||
});
|
||||
|
||||
$validator->sometimes('allocation_additional.*', [
|
||||
|
@ -54,7 +54,7 @@ class ServerFormRequest extends AdminFormRequest
|
|||
$query->whereNull('server_id');
|
||||
}),
|
||||
], function ($input) {
|
||||
return ! ($input->auto_deploy);
|
||||
return !($input->auto_deploy);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -10,8 +10,6 @@ class StoreServerDatabaseRequest extends AdminFormRequest
|
|||
{
|
||||
/**
|
||||
* Validation rules for database creation.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
|
|
|
@ -30,6 +30,7 @@ class MailSettingsFormRequest extends AdminFormRequest
|
|||
* as we need to accept empty values on the keys.
|
||||
*
|
||||
* @param array $only
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function normalize(array $only = null)
|
||||
|
|
|
@ -22,8 +22,6 @@ class DeleteAllocationRequest extends ApplicationApiRequest
|
|||
/**
|
||||
* Determine if the requested allocation exists and belongs to the node that
|
||||
* is being passed in the URL.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
|
|
|
@ -21,8 +21,6 @@ class GetAllocationsRequest extends ApplicationApiRequest
|
|||
/**
|
||||
* Determine if the node that we are requesting the allocations
|
||||
* for exists on the Panel.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
|
|
|
@ -17,9 +17,6 @@ class StoreAllocationRequest extends ApplicationApiRequest
|
|||
*/
|
||||
protected $permission = AdminAcl::WRITE;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
@ -40,8 +40,6 @@ abstract class ApplicationApiRequest extends FormRequest
|
|||
* Determine if the current user is authorized to perform
|
||||
* the requested action against the API.
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\PterodactylException
|
||||
*/
|
||||
public function authorize(): bool
|
||||
|
@ -55,8 +53,6 @@ abstract class ApplicationApiRequest extends FormRequest
|
|||
|
||||
/**
|
||||
* Determine if the requested resource exists on the server.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
|
@ -65,8 +61,6 @@ abstract class ApplicationApiRequest extends FormRequest
|
|||
|
||||
/**
|
||||
* Default set of rules to apply to API requests.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
|
@ -75,8 +69,6 @@ abstract class ApplicationApiRequest extends FormRequest
|
|||
|
||||
/**
|
||||
* Return the API key being used for the request.
|
||||
*
|
||||
* @return \Pterodactyl\Models\ApiKey
|
||||
*/
|
||||
public function key(): ApiKey
|
||||
{
|
||||
|
@ -87,8 +79,8 @@ abstract class ApplicationApiRequest extends FormRequest
|
|||
* Grab a model from the route parameters. If no model is found in the
|
||||
* binding mappings an exception will be thrown.
|
||||
*
|
||||
* @param string $model
|
||||
* @return mixed
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @throws \Symfony\Component\Routing\Exception\InvalidParameterException
|
||||
|
@ -98,7 +90,7 @@ abstract class ApplicationApiRequest extends FormRequest
|
|||
$parameterKey = array_get(array_flip(ApiSubstituteBindings::getMappings()), $model);
|
||||
|
||||
if (is_null($parameterKey)) {
|
||||
throw new InvalidParameterException;
|
||||
throw new InvalidParameterException();
|
||||
}
|
||||
|
||||
return $this->route()->parameter($parameterKey);
|
||||
|
@ -112,7 +104,7 @@ abstract class ApplicationApiRequest extends FormRequest
|
|||
*/
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
if (! $this->passesAuthorization()) {
|
||||
if (!$this->passesAuthorization()) {
|
||||
$this->failedAuthorization();
|
||||
}
|
||||
|
||||
|
@ -137,7 +129,7 @@ abstract class ApplicationApiRequest extends FormRequest
|
|||
return true;
|
||||
}
|
||||
|
||||
if (! parent::passesAuthorization()) {
|
||||
if (!parent::passesAuthorization()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -145,7 +137,7 @@ abstract class ApplicationApiRequest extends FormRequest
|
|||
// authenticated to access the endpoint. This avoids exposing that
|
||||
// an item exists (or does not exist) to the user until they can prove
|
||||
// that they have permission to know about it.
|
||||
if ($this->attributes->get('is_missing_model', false) || ! $this->resourceExists()) {
|
||||
if ($this->attributes->get('is_missing_model', false) || !$this->resourceExists()) {
|
||||
throw new NotFoundHttpException(trans('exceptions.api.resource_not_found'));
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,6 @@ class DeleteLocationRequest extends ApplicationApiRequest
|
|||
|
||||
/**
|
||||
* Determine if the requested location exists on the Panel.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
|
|
|
@ -8,8 +8,6 @@ class GetLocationRequest extends GetLocationsRequest
|
|||
{
|
||||
/**
|
||||
* Determine if the requested location exists on the Panel.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
|
|
|
@ -20,8 +20,6 @@ class StoreLocationRequest extends ApplicationApiRequest
|
|||
|
||||
/**
|
||||
* Rules to validate the request against.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
|
|
|
@ -8,8 +8,6 @@ class UpdateLocationRequest extends StoreLocationRequest
|
|||
{
|
||||
/**
|
||||
* Determine if the requested location exists on the Panel.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
|
@ -20,8 +18,6 @@ class UpdateLocationRequest extends StoreLocationRequest
|
|||
|
||||
/**
|
||||
* Rules to validate this request against.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
|
|
|
@ -21,8 +21,6 @@ class GetEggRequest extends ApplicationApiRequest
|
|||
|
||||
/**
|
||||
* Determine if the requested egg exists for the selected nest.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
|
|
|
@ -21,8 +21,6 @@ class DeleteNodeRequest extends ApplicationApiRequest
|
|||
/**
|
||||
* Determine if the node being requested for editing exists
|
||||
* on the Panel before validating the data.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
|
|
|
@ -8,8 +8,6 @@ class GetNodeRequest extends GetNodesRequest
|
|||
{
|
||||
/**
|
||||
* Determine if the requested node exists on the Panel.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
|
|
|
@ -20,9 +20,6 @@ class StoreNodeRequest extends ApplicationApiRequest
|
|||
|
||||
/**
|
||||
* Validation rules to apply to this request.
|
||||
*
|
||||
* @param array|null $rules
|
||||
* @return array
|
||||
*/
|
||||
public function rules(array $rules = null): array
|
||||
{
|
||||
|
@ -74,7 +71,7 @@ class StoreNodeRequest extends ApplicationApiRequest
|
|||
$response = parent::validated();
|
||||
$response['daemonListen'] = $response['daemon_listen'];
|
||||
$response['daemonSFTP'] = $response['daemon_sftp'];
|
||||
$response['daemonBase'] = $response['daemon_base'] ?? (new Node)->getAttribute('daemonBase');
|
||||
$response['daemonBase'] = $response['daemon_base'] ?? (new Node())->getAttribute('daemonBase');
|
||||
|
||||
unset($response['daemon_base'], $response['daemon_listen'], $response['daemon_sftp']);
|
||||
|
||||
|
|
|
@ -9,9 +9,6 @@ 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.
|
||||
*
|
||||
* @param array|null $rules
|
||||
* @return array
|
||||
*/
|
||||
public function rules(array $rules = null): array
|
||||
{
|
||||
|
|
|
@ -19,8 +19,6 @@ class GetServerDatabaseRequest extends ApplicationApiRequest
|
|||
|
||||
/**
|
||||
* Determine if the requested server database exists.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
|
|
|
@ -24,8 +24,6 @@ class StoreServerDatabaseRequest extends ApplicationApiRequest
|
|||
|
||||
/**
|
||||
* Validation rules for database creation.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
|
@ -76,8 +74,6 @@ class StoreServerDatabaseRequest extends ApplicationApiRequest
|
|||
|
||||
/**
|
||||
* Returns the database name in the expected format.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function databaseName(): string
|
||||
{
|
||||
|
|
|
@ -27,8 +27,6 @@ class GetExternalServerRequest extends ApplicationApiRequest
|
|||
|
||||
/**
|
||||
* Determine if the requested external user exists.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
|
@ -47,8 +45,6 @@ class GetExternalServerRequest extends ApplicationApiRequest
|
|||
|
||||
/**
|
||||
* Return the server model for the requested external server.
|
||||
*
|
||||
* @return \Pterodactyl\Models\Server
|
||||
*/
|
||||
public function getServerModel(): Server
|
||||
{
|
||||
|
|
|
@ -4,9 +4,6 @@ namespace Pterodactyl\Http\Requests\Api\Application\Servers;
|
|||
|
||||
class GetServersRequest extends GetServerRequest
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
@ -23,8 +23,6 @@ class StoreServerRequest extends ApplicationApiRequest
|
|||
|
||||
/**
|
||||
* Rules to be applied to this request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
|
@ -120,7 +118,7 @@ class StoreServerRequest extends ApplicationApiRequest
|
|||
$query->whereNull('server_id');
|
||||
}),
|
||||
], function ($input) {
|
||||
return ! ($input->deploy);
|
||||
return !($input->deploy);
|
||||
});
|
||||
|
||||
$validator->sometimes('allocation.additional.*', [
|
||||
|
@ -129,7 +127,7 @@ class StoreServerRequest extends ApplicationApiRequest
|
|||
$query->whereNull('server_id');
|
||||
}),
|
||||
], function ($input) {
|
||||
return ! ($input->deploy);
|
||||
return !($input->deploy);
|
||||
});
|
||||
|
||||
$validator->sometimes('deploy.locations', 'present', function ($input) {
|
||||
|
@ -152,7 +150,7 @@ class StoreServerRequest extends ApplicationApiRequest
|
|||
return null;
|
||||
}
|
||||
|
||||
$object = new DeploymentObject;
|
||||
$object = new DeploymentObject();
|
||||
$object->setDedicated($this->input('deploy.dedicated_ip', false));
|
||||
$object->setLocations($this->input('deploy.locations', []));
|
||||
$object->setPorts($this->input('deploy.port_range', []));
|
||||
|
|
|
@ -9,8 +9,6 @@ class UpdateServerBuildConfigurationRequest extends ServerWriteRequest
|
|||
{
|
||||
/**
|
||||
* Return the rules to validate this request against.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
|
@ -67,7 +65,7 @@ class UpdateServerBuildConfigurationRequest extends ServerWriteRequest
|
|||
unset($data['allocation'], $data['feature_limits']);
|
||||
|
||||
// Adjust the limits field to match what is expected by the model.
|
||||
if (! empty($data['limits'])) {
|
||||
if (!empty($data['limits'])) {
|
||||
foreach ($data['limits'] as $key => $value) {
|
||||
$data[$key] = $value;
|
||||
}
|
||||
|
@ -101,16 +99,13 @@ class UpdateServerBuildConfigurationRequest extends ServerWriteRequest
|
|||
* compatability with the old API endpoint while also supporting a more correct API
|
||||
* call.
|
||||
*
|
||||
* @param string $field
|
||||
* @param array $rules
|
||||
* @param bool $limits
|
||||
* @return array
|
||||
*
|
||||
* @see https://github.com/pterodactyl/panel/issues/1500
|
||||
*/
|
||||
protected function requiredToOptional(string $field, array $rules, bool $limits = false)
|
||||
{
|
||||
if (! in_array('required', $rules)) {
|
||||
if (!in_array('required', $rules)) {
|
||||
return $rules;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@ class UpdateServerDetailsRequest extends ServerWriteRequest
|
|||
{
|
||||
/**
|
||||
* Rules to apply to a server details update request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
|
@ -26,8 +24,6 @@ class UpdateServerDetailsRequest extends ServerWriteRequest
|
|||
/**
|
||||
* Convert the posted data into the correct format that is expected
|
||||
* by the application.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function validated(): array
|
||||
{
|
||||
|
@ -42,8 +38,6 @@ class UpdateServerDetailsRequest extends ServerWriteRequest
|
|||
/**
|
||||
* Rename some of the attributes in error messages to clarify the field
|
||||
* being discussed.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function attributes(): array
|
||||
{
|
||||
|
|
|
@ -20,8 +20,6 @@ class UpdateServerStartupRequest extends ApplicationApiRequest
|
|||
|
||||
/**
|
||||
* Validation rules to run the input against.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
|
|
|
@ -20,8 +20,6 @@ class DeleteUserRequest extends ApplicationApiRequest
|
|||
|
||||
/**
|
||||
* Determine if the requested user exists on the Panel.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
|
|
|
@ -27,8 +27,6 @@ class GetExternalUserRequest extends ApplicationApiRequest
|
|||
|
||||
/**
|
||||
* Determine if the requested external user exists.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
|
@ -47,8 +45,6 @@ class GetExternalUserRequest extends ApplicationApiRequest
|
|||
|
||||
/**
|
||||
* Return the user model for the requested external user.
|
||||
*
|
||||
* @return \Pterodactyl\Models\User
|
||||
*/
|
||||
public function getUserModel(): User
|
||||
{
|
||||
|
|
|
@ -20,9 +20,6 @@ class StoreUserRequest extends ApplicationApiRequest
|
|||
|
||||
/**
|
||||
* Return the validation rules for this request.
|
||||
*
|
||||
* @param array|null $rules
|
||||
* @return array
|
||||
*/
|
||||
public function rules(array $rules = null): array
|
||||
{
|
||||
|
|
|
@ -8,9 +8,6 @@ class UpdateUserRequest extends StoreUserRequest
|
|||
{
|
||||
/**
|
||||
* Return the validation rules for this request.
|
||||
*
|
||||
* @param array|null $rules
|
||||
* @return array
|
||||
*/
|
||||
public function rules(array $rules = null): array
|
||||
{
|
||||
|
|
|
@ -7,9 +7,6 @@ use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest;
|
|||
|
||||
class StoreApiKeyRequest extends ClientApiRequest
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = ApiKey::getRules();
|
||||
|
|
|
@ -9,27 +9,22 @@ use Pterodactyl\Exceptions\Http\Base\InvalidPasswordProvidedException;
|
|||
class UpdateEmailRequest extends ClientApiRequest
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Http\Base\InvalidPasswordProvidedException
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
if (! parent::authorize()) {
|
||||
if (!parent::authorize()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Verify password matches when changing password or email.
|
||||
if (! password_verify($this->input('password'), $this->user()->password)) {
|
||||
if (!password_verify($this->input('password'), $this->user()->password)) {
|
||||
throw new InvalidPasswordProvidedException(trans('validation.internal.invalid_password'));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = User::getRulesForUpdate($this->user());
|
||||
|
|
|
@ -8,27 +8,22 @@ use Pterodactyl\Exceptions\Http\Base\InvalidPasswordProvidedException;
|
|||
class UpdatePasswordRequest extends ClientApiRequest
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Http\Base\InvalidPasswordProvidedException
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
if (! parent::authorize()) {
|
||||
if (!parent::authorize()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Verify password matches when changing password or email.
|
||||
if (! password_verify($this->input('current_password'), $this->user()->password)) {
|
||||
if (!password_verify($this->input('current_password'), $this->user()->password)) {
|
||||
throw new InvalidPasswordProvidedException(trans('validation.internal.invalid_password'));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
@ -13,8 +13,6 @@ class ClientApiRequest extends ApplicationApiRequest
|
|||
{
|
||||
/**
|
||||
* Determine if the current user is authorized to perform the requested action against the API.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
|
|
|
@ -4,9 +4,6 @@ namespace Pterodactyl\Http\Requests\Api\Client;
|
|||
|
||||
class GetServersRequest extends ClientApiRequest
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
|
|
|
@ -15,9 +15,6 @@ class StoreBackupRequest extends ClientApiRequest
|
|||
return Permission::ACTION_BACKUP_CREATE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
@ -10,17 +10,11 @@ use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest;
|
|||
|
||||
class DeleteDatabaseRequest extends ClientApiRequest implements ClientPermissionsRequest
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function permission(): string
|
||||
{
|
||||
return Permission::ACTION_DATABASE_DELETE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
return $this->getModel(Server::class)->id === $this->getModel(Database::class)->server_id;
|
||||
|
|
|
@ -8,9 +8,6 @@ use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest;
|
|||
|
||||
class GetDatabasesRequest extends ClientApiRequest implements ClientPermissionsRequest
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function permission(): string
|
||||
{
|
||||
return Permission::ACTION_DATABASE_READ;
|
||||
|
|
|
@ -9,8 +9,6 @@ class RotatePasswordRequest extends ClientApiRequest
|
|||
{
|
||||
/**
|
||||
* Check that the user has permission to rotate the password.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function permission(): string
|
||||
{
|
||||
|
|
|
@ -13,17 +13,11 @@ use Pterodactyl\Services\Databases\DatabaseManagementService;
|
|||
|
||||
class StoreDatabaseRequest extends ClientApiRequest implements ClientPermissionsRequest
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function permission(): string
|
||||
{
|
||||
return Permission::ACTION_DATABASE_CREATE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$server = $this->route()->parameter('server');
|
||||
|
|
|
@ -8,17 +8,11 @@ use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest;
|
|||
|
||||
class ChmodFilesRequest extends ClientApiRequest implements ClientPermissionsRequest
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function permission(): string
|
||||
{
|
||||
return Permission::ACTION_FILE_UPDATE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
@ -9,17 +9,12 @@ class CompressFilesRequest extends ClientApiRequest
|
|||
{
|
||||
/**
|
||||
* Checks that the authenticated user is allowed to create archives for this server.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function permission(): string
|
||||
{
|
||||
return Permission::ACTION_FILE_ARCHIVE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
@ -8,17 +8,11 @@ use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest;
|
|||
|
||||
class CopyFileRequest extends ClientApiRequest implements ClientPermissionsRequest
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function permission(): string
|
||||
{
|
||||
return Permission::ACTION_FILE_CREATE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
@ -9,17 +9,12 @@ class CreateFolderRequest extends ClientApiRequest
|
|||
{
|
||||
/**
|
||||
* Checks that the authenticated user is allowed to create files on the server.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function permission(): string
|
||||
{
|
||||
return Permission::ACTION_FILE_CREATE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
@ -11,17 +11,12 @@ class DecompressFilesRequest extends ClientApiRequest
|
|||
* Checks that the authenticated user is allowed to create new files for the server. We don't
|
||||
* rely on the archive permission here as it makes more sense to make sure the user can create
|
||||
* additional files rather than make an archive.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function permission(): string
|
||||
{
|
||||
return Permission::ACTION_FILE_CREATE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
@ -8,17 +8,11 @@ use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest;
|
|||
|
||||
class DeleteFileRequest extends ClientApiRequest implements ClientPermissionsRequest
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function permission(): string
|
||||
{
|
||||
return Permission::ACTION_FILE_DELETE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
@ -10,8 +10,6 @@ class DownloadFileRequest extends ClientApiRequest
|
|||
/**
|
||||
* Ensure that the user making this request has permission to download files
|
||||
* from this server.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
|
|
|
@ -12,17 +12,12 @@ class GetFileContentsRequest extends ClientApiRequest implements ClientPermissio
|
|||
* Returns the permissions string indicating which permission should be used to
|
||||
* validate that the authenticated user has permission to perform this action aganist
|
||||
* the given resource (server).
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function permission(): string
|
||||
{
|
||||
return Permission::ACTION_FILE_READ_CONTENT;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
@ -10,17 +10,12 @@ class ListFilesRequest extends ClientApiRequest
|
|||
/**
|
||||
* Check that the user making this request to the API is authorized to list all
|
||||
* of the files that exist for a given server.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function permission(): string
|
||||
{
|
||||
return Permission::ACTION_FILE_READ;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
@ -8,9 +8,6 @@ use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest;
|
|||
|
||||
class PullFileRequest extends ClientApiRequest implements ClientPermissionsRequest
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function permission(): string
|
||||
{
|
||||
return Permission::ACTION_FILE_CREATE;
|
||||
|
|
|
@ -11,17 +11,12 @@ class RenameFileRequest extends ClientApiRequest implements ClientPermissionsReq
|
|||
/**
|
||||
* The permission the user is required to have in order to perform this
|
||||
* request action.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function permission(): string
|
||||
{
|
||||
return Permission::ACTION_FILE_UPDATE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
@ -12,8 +12,6 @@ class WriteFileContentRequest extends ClientApiRequest implements ClientPermissi
|
|||
* Returns the permissions string indicating which permission should be used to
|
||||
* validate that the authenticated user has permission to perform this action aganist
|
||||
* the given resource (server).
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function permission(): string
|
||||
{
|
||||
|
@ -24,8 +22,6 @@ class WriteFileContentRequest extends ClientApiRequest implements ClientPermissi
|
|||
* There is no rule here for the file contents since we just use the body content
|
||||
* on the request to set the file contents. If nothing is passed that is fine since
|
||||
* it just means we want to set the file to be empty.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
|
|
|
@ -10,8 +10,6 @@ class GetServerRequest extends ClientApiRequest
|
|||
* Determine if a client has permission to view this server on the API. This
|
||||
* should never be false since this would be checking the same permission as
|
||||
* resourceExists().
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
|
|
|
@ -7,9 +7,6 @@ use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest;
|
|||
|
||||
class DeleteAllocationRequest extends ClientApiRequest
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function permission(): string
|
||||
{
|
||||
return Permission::ACTION_ALLOCATION_DELETE;
|
||||
|
|
|
@ -10,8 +10,6 @@ class GetNetworkRequest extends ClientApiRequest
|
|||
/**
|
||||
* Check that the user has permission to view the allocations for
|
||||
* this server.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function permission(): string
|
||||
{
|
||||
|
|
|
@ -7,9 +7,6 @@ use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest;
|
|||
|
||||
class NewAllocationRequest extends ClientApiRequest
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function permission(): string
|
||||
{
|
||||
return Permission::ACTION_ALLOCATION_CREATE;
|
||||
|
|
|
@ -4,9 +4,6 @@ namespace Pterodactyl\Http\Requests\Api\Client\Servers\Network;
|
|||
|
||||
class SetPrimaryAllocationRequest extends UpdateAllocationRequest
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [];
|
||||
|
|
|
@ -8,17 +8,11 @@ use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest;
|
|||
|
||||
class UpdateAllocationRequest extends ClientApiRequest
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function permission(): string
|
||||
{
|
||||
return Permission::ACTION_ALLOCATION_UPDATE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = Allocation::getRules();
|
||||
|
|
|
@ -6,9 +6,6 @@ use Pterodactyl\Models\Permission;
|
|||
|
||||
class DeleteScheduleRequest extends ViewScheduleRequest
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function permission(): string
|
||||
{
|
||||
return Permission::ACTION_SCHEDULE_DELETE;
|
||||
|
|
|
@ -7,17 +7,11 @@ use Pterodactyl\Models\Permission;
|
|||
|
||||
class StoreScheduleRequest extends ViewScheduleRequest
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function permission(): string
|
||||
{
|
||||
return Permission::ACTION_SCHEDULE_CREATE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = Schedule::getRules();
|
||||
|
|
|
@ -10,17 +10,12 @@ class StoreTaskRequest extends ViewScheduleRequest
|
|||
* Determine if the user is allowed to create a new task for this schedule. We simply
|
||||
* check if they can modify a schedule to determine if they're able to do this. There
|
||||
* are no task specific permissions.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function permission(): string
|
||||
{
|
||||
return Permission::ACTION_SCHEDULE_UPDATE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
@ -7,17 +7,11 @@ use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest;
|
|||
|
||||
class TriggerScheduleRequest extends ClientApiRequest
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function permission(): string
|
||||
{
|
||||
return Permission::ACTION_SCHEDULE_UPDATE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [];
|
||||
|
|
|
@ -6,9 +6,6 @@ use Pterodactyl\Models\Permission;
|
|||
|
||||
class UpdateScheduleRequest extends StoreScheduleRequest
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function permission(): string
|
||||
{
|
||||
return Permission::ACTION_SCHEDULE_UPDATE;
|
||||
|
|
|
@ -13,12 +13,10 @@ class ViewScheduleRequest extends ClientApiRequest
|
|||
{
|
||||
/**
|
||||
* Determine if this resource can be viewed.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
if (! parent::authorize()) {
|
||||
if (!parent::authorize()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -31,18 +29,13 @@ class ViewScheduleRequest extends ClientApiRequest
|
|||
$task = $this->route()->parameter('task');
|
||||
|
||||
if ($schedule->server_id !== $server->id || ($task instanceof Task && $task->schedule_id !== $schedule->id)) {
|
||||
throw new NotFoundHttpException(
|
||||
'The requested resource does not exist on the system.'
|
||||
);
|
||||
throw new NotFoundHttpException('The requested resource does not exist on the system.');
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function permission(): string
|
||||
{
|
||||
return Permission::ACTION_SCHEDULE_READ;
|
||||
|
|
|
@ -9,8 +9,6 @@ class SendCommandRequest extends ClientApiRequest
|
|||
{
|
||||
/**
|
||||
* Determine if the API user has permission to perform this action.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function permission(): string
|
||||
{
|
||||
|
@ -19,8 +17,6 @@ class SendCommandRequest extends ClientApiRequest
|
|||
|
||||
/**
|
||||
* Rules to validate this request against.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
|
|
|
@ -9,8 +9,6 @@ class SendPowerRequest extends ClientApiRequest
|
|||
{
|
||||
/**
|
||||
* Determine if the user has permission to send a power command to a server.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function permission(): string
|
||||
{
|
||||
|
@ -29,8 +27,6 @@ class SendPowerRequest extends ClientApiRequest
|
|||
|
||||
/**
|
||||
* Rules to validate this request against.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
|
|
|
@ -13,8 +13,6 @@ class RenameServerRequest extends ClientApiRequest implements ClientPermissionsR
|
|||
* Returns the permissions string indicating which permission should be used to
|
||||
* validate that the authenticated user has permission to perform this action aganist
|
||||
* the given resource (server).
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function permission(): string
|
||||
{
|
||||
|
@ -23,8 +21,6 @@ class RenameServerRequest extends ClientApiRequest implements ClientPermissionsR
|
|||
|
||||
/**
|
||||
* The rules to apply when validating this request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
|
|
|
@ -11,9 +11,6 @@ use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest;
|
|||
|
||||
class SetDockerImageRequest extends ClientApiRequest implements ClientPermissionsRequest
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function permission(): string
|
||||
{
|
||||
return Permission::ACTION_STARTUP_DOCKER_IMAGE;
|
||||
|
|
|
@ -8,8 +8,6 @@ class GetSubuserRequest extends SubuserRequest
|
|||
{
|
||||
/**
|
||||
* Confirm that a user is able to view subusers for the specified server.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function permission(): string
|
||||
{
|
||||
|
|
|
@ -14,9 +14,6 @@ class StoreSubuserRequest extends SubuserRequest
|
|||
return Permission::ACTION_USER_CREATE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
@ -18,13 +18,11 @@ abstract class SubuserRequest extends ClientApiRequest
|
|||
/**
|
||||
* Authorize the request and ensure that a user is not trying to modify themselves.
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
if (! parent::authorize()) {
|
||||
if (!parent::authorize()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -51,8 +49,6 @@ abstract class SubuserRequest extends ClientApiRequest
|
|||
* Validates that the permissions we are trying to assign can actually be assigned
|
||||
* by the user making the request.
|
||||
*
|
||||
* @param array $permissions
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
protected function validatePermissionsCanBeAssigned(array $permissions)
|
||||
|
@ -74,9 +70,7 @@ abstract class SubuserRequest extends ClientApiRequest
|
|||
$service = $this->container->make(GetUserPermissionsService::class);
|
||||
|
||||
if (count(array_diff($permissions, $service->handle($server, $user))) > 0) {
|
||||
throw new HttpForbiddenException(
|
||||
'Cannot assign permissions to a subuser that your account does not actively possess.'
|
||||
);
|
||||
throw new HttpForbiddenException('Cannot assign permissions to a subuser that your account does not actively possess.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,9 +14,6 @@ class UpdateSubuserRequest extends SubuserRequest
|
|||
return Permission::ACTION_USER_UPDATE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
@ -9,8 +9,6 @@ class LoginCheckpointRequest extends FormRequest
|
|||
{
|
||||
/**
|
||||
* Determine if the request is authorized.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
|
@ -19,8 +17,6 @@ class LoginCheckpointRequest extends FormRequest
|
|||
|
||||
/**
|
||||
* Rules to apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
|
|
|
@ -6,17 +6,11 @@ use Illuminate\Foundation\Http\FormRequest;
|
|||
|
||||
class LoginRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function authorized(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
@ -6,17 +6,11 @@ use Illuminate\Foundation\Http\FormRequest;
|
|||
|
||||
class ResetPasswordRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
@ -22,7 +22,7 @@ abstract class FrontendUserFormRequest extends FormRequest
|
|||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return ! is_null($this->user());
|
||||
return !is_null($this->user());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Reference in a new issue