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;
|
|
|
|
|
2021-08-05 03:55:15 +00:00
|
|
|
abstract class ClientApiRequest extends ApplicationApiRequest implements ClientPermissionsRequest
|
2018-02-28 03:28:43 +00:00
|
|
|
{
|
|
|
|
/**
|
2021-08-05 03:55:15 +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
|
|
|
*/
|
|
|
|
public function authorize(): bool
|
|
|
|
{
|
2021-08-05 03:55:15 +00:00
|
|
|
$server = $this->route()->parameter('server');
|
2020-03-22 20:56:15 +00:00
|
|
|
|
2021-08-05 03:55:15 +00:00
|
|
|
if ($server instanceof Server) {
|
|
|
|
return $this->user()->can($this->permission(), $server);
|
2018-08-23 05:29:20 +00:00
|
|
|
}
|
|
|
|
|
2021-08-05 03:55:15 +00:00
|
|
|
// If there is no server available on the reqest, trigger a failure since
|
|
|
|
// we expect there to be one at this point.
|
|
|
|
return false;
|
2018-02-28 03:28:43 +00:00
|
|
|
}
|
|
|
|
}
|