2018-02-28 03:28:43 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Http\Requests\Api\Client;
|
|
|
|
|
2018-08-23 05:29:20 +00:00
|
|
|
use Pterodactyl\Models\Server;
|
|
|
|
use Pterodactyl\Contracts\Http\ClientPermissionsRequest;
|
2018-02-28 03:28:43 +00:00
|
|
|
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
|
|
|
|
|
|
|
abstract class ClientApiRequest extends ApplicationApiRequest
|
|
|
|
{
|
|
|
|
/**
|
2018-08-23 05:29:20 +00:00
|
|
|
* Determine if the current user is authorized to perform the requested action against the API.
|
2018-02-28 03:28:43 +00:00
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function authorize(): bool
|
|
|
|
{
|
2018-08-23 05:29:20 +00:00
|
|
|
if ($this instanceof ClientPermissionsRequest || method_exists($this, 'permission')) {
|
|
|
|
return $this->user()->can($this->permission(), $this->getModel(Server::class));
|
|
|
|
}
|
|
|
|
|
2018-02-28 03:28:43 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|