misc_pterodactyl-panel/app/Http/Requests/Api/Client/ClientApiRequest.php

29 lines
765 B
PHP
Raw Normal View History

<?php
namespace Pterodactyl\Http\Requests\Api\Client;
2019-09-06 04:32:57 +00:00
use Pterodactyl\Models\User;
use Pterodactyl\Models\Server;
use Pterodactyl\Contracts\Http\ClientPermissionsRequest;
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
2019-07-27 22:17:50 +00:00
/**
2019-09-06 04:32:57 +00:00
* @method User user($guard = null)
2019-07-27 22:17:50 +00:00
*/
abstract class ClientApiRequest extends ApplicationApiRequest
{
/**
* Determine if the current user is authorized to perform the requested action against the API.
*
* @return bool
*/
public function authorize(): bool
{
if ($this instanceof ClientPermissionsRequest || method_exists($this, 'permission')) {
return $this->user()->can($this->permission(), $this->getModel(Server::class));
}
return true;
}
}