Add base routes for managing servers as a client

This commit is contained in:
Dane Everitt 2018-02-27 21:28:43 -06:00
parent 9a32b9fd03
commit cef3e4ced4
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
18 changed files with 262 additions and 270 deletions

View file

@ -0,0 +1,19 @@
<?php
namespace Pterodactyl\Http\Requests\Api\Client;
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
abstract class ClientApiRequest extends ApplicationApiRequest
{
/**
* Determine if the current user is authorized to perform
* the requested action aganist the API.
*
* @return bool
*/
public function authorize(): bool
{
return true;
}
}

View file

@ -0,0 +1,14 @@
<?php
namespace Pterodactyl\Http\Requests\Api\Client;
class GetServersRequest extends ClientApiRequest
{
/**
* @return bool
*/
public function authorize(): bool
{
return true;
}
}

View file

@ -0,0 +1,31 @@
<?php
namespace Pterodactyl\Http\Requests\Api\Client\Servers;
use Pterodactyl\Models\Server;
use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest;
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
{
return true;
}
/**
* Determine if the user should even know that this server exists.
*
* @return bool
*/
public function resourceExists(): bool
{
return $this->user()->can('view-server', $this->getModel(Server::class));
}
}