2020-03-27 14:23:13 -07:00
|
|
|
<?php
|
|
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2020-03-27 14:23:13 -07:00
|
|
|
namespace Pterodactyl\Http\Requests\Api\Client\Servers\Subusers;
|
|
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
use Pterodactyl\Enum\Permissions;
|
2026-10-06 01:17:42 +01:00
|
|
|
use Pterodactyl\Exceptions\Http\HttpForbiddenException;
|
2020-03-27 14:23:13 -07:00
|
|
|
|
2020-03-27 16:57:49 -07:00
|
|
|
class DeleteSubuserRequest extends SubuserRequest
|
2020-03-27 14:23:13 -07:00
|
|
|
{
|
2022-10-14 10:59:20 -06:00
|
|
|
public function permission(): string
|
2020-03-27 14:23:13 -07:00
|
|
|
{
|
2026-10-05 18:10:18 -04:00
|
|
|
return Permissions::UserDelete->value;
|
2020-03-27 14:23:13 -07:00
|
|
|
}
|
2026-10-06 01:17:42 +01:00
|
|
|
|
|
|
|
|
public function authorize(): bool
|
|
|
|
|
{
|
|
|
|
|
if (! parent::authorize()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($this->requesterHasFullAccess()) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$exceeding = array_diff($this->subuser()->permissions, $this->requesterPermissions(), [Permissions::WebsocketConnect->value]);
|
|
|
|
|
|
|
|
|
|
throw_if(count($exceeding) > 0, HttpForbiddenException::class, 'Cannot remove a subuser that has permissions your account does not actively possess.');
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2020-03-27 14:23:13 -07:00
|
|
|
}
|