Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/app/Http/Requests/Api/Client/ClientApiRequest.php
10266 views
1
<?php
2
3
namespace Pterodactyl\Http\Requests\Api\Client;
4
5
use Pterodactyl\Models\Server;
6
use Pterodactyl\Contracts\Http\ClientPermissionsRequest;
7
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
8
9
/**
10
* @method \Pterodactyl\Models\User user($guard = null)
11
*/
12
class ClientApiRequest extends ApplicationApiRequest
13
{
14
/**
15
* Determine if the current user is authorized to perform the requested action against the API.
16
*/
17
public function authorize(): bool
18
{
19
if ($this instanceof ClientPermissionsRequest || method_exists($this, 'permission')) {
20
$server = $this->route()->parameter('server');
21
22
if ($server instanceof Server) {
23
return $this->user()->can($this->permission(), $server);
24
}
25
26
// If there is no server available on the reqest, trigger a failure since
27
// we expect there to be one at this point.
28
return false;
29
}
30
31
return true;
32
}
33
}
34
35