2018-02-27 21:28:43 -06:00
|
|
|
<?php
|
|
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2018-02-27 21:28:43 -06:00
|
|
|
namespace Pterodactyl\Http\Requests\Api\Client;
|
|
|
|
|
|
2018-08-22 22:29:20 -07:00
|
|
|
use Pterodactyl\Contracts\Http\ClientPermissionsRequest;
|
2018-02-27 21:28:43 -06:00
|
|
|
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
2026-10-05 18:10:18 -04:00
|
|
|
use Pterodactyl\Models\Server;
|
|
|
|
|
use Pterodactyl\Models\User;
|
2018-02-27 21:28:43 -06:00
|
|
|
|
2019-07-27 15:17:50 -07:00
|
|
|
/**
|
2026-10-05 18:10:18 -04:00
|
|
|
* @method User user($guard = null)
|
2019-07-27 15:17:50 -07:00
|
|
|
*/
|
2020-03-18 21:08:32 -07:00
|
|
|
class ClientApiRequest extends ApplicationApiRequest
|
2018-02-27 21:28:43 -06:00
|
|
|
{
|
|
|
|
|
/**
|
2018-08-22 22:29:20 -07:00
|
|
|
* Determine if the current user is authorized to perform the requested action against the API.
|
2018-02-27 21:28:43 -06:00
|
|
|
*/
|
|
|
|
|
public function authorize(): bool
|
|
|
|
|
{
|
2026-10-05 18:10:18 -04:00
|
|
|
if ($this instanceof ClientPermissionsRequest) {
|
|
|
|
|
$server = $this->parameter('server', Server::class);
|
2020-03-22 13:56:15 -07:00
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
return $this->user()->can($this->permission(), $server);
|
2018-08-22 22:29:20 -07:00
|
|
|
}
|
|
|
|
|
|
2018-02-27 21:28:43 -06:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|