Use more standardized phpcs
This commit is contained in:
parent
a043071e3c
commit
c449ca5155
493 changed files with 1116 additions and 3903 deletions
|
@ -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;
|
||||
|
|
|
@ -20,8 +20,6 @@ class DownloadBackupRequest extends ClientApiRequest
|
|||
/**
|
||||
* Ensure that this backup belongs to the server that is also present in the
|
||||
* request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
|
|
|
@ -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 [
|
||||
|
|
Reference in a new issue