Update the client API to be consistent with how validation is handled
This commit is contained in:
parent
b47d262ee0
commit
622d292f39
33 changed files with 59 additions and 172 deletions
|
@ -6,28 +6,22 @@ use Pterodactyl\Models\Server;
|
|||
use Pterodactyl\Contracts\Http\ClientPermissionsRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||
|
||||
/**
|
||||
* @method \Pterodactyl\Models\User user($guard = null)
|
||||
*/
|
||||
class ClientApiRequest extends ApplicationApiRequest
|
||||
abstract class ClientApiRequest extends ApplicationApiRequest implements ClientPermissionsRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the current user is authorized to perform the requested action against the API.
|
||||
* Determine if the current user is authorized to perform the requested action
|
||||
* against the API.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
if ($this instanceof ClientPermissionsRequest || method_exists($this, 'permission')) {
|
||||
$server = $this->route()->parameter('server');
|
||||
$server = $this->route()->parameter('server');
|
||||
|
||||
if ($server instanceof Server) {
|
||||
return $this->user()->can($this->permission(), $server);
|
||||
}
|
||||
|
||||
// If there is no server available on the reqest, trigger a failure since
|
||||
// we expect there to be one at this point.
|
||||
return false;
|
||||
if ($server instanceof Server) {
|
||||
return $this->user()->can($this->permission(), $server);
|
||||
}
|
||||
|
||||
return true;
|
||||
// If there is no server available on the reqest, trigger a failure since
|
||||
// we expect there to be one at this point.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue