2018-02-28 03:28:43 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Http\Requests\Api\Client;
|
|
|
|
|
2019-09-06 04:32:57 +00:00
|
|
|
use Pterodactyl\Models\User;
|
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;
|
|
|
|
|
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
|
|
|
*/
|
2018-02-28 03:28:43 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|