diff --git a/app/Http/Controllers/Api/Client/Servers/WebsocketController.php b/app/Http/Controllers/Api/Client/Servers/WebsocketController.php index b3ddaae9..1de41b08 100644 --- a/app/Http/Controllers/Api/Client/Servers/WebsocketController.php +++ b/app/Http/Controllers/Api/Client/Servers/WebsocketController.php @@ -3,12 +3,11 @@ namespace Pterodactyl\Http\Controllers\Api\Client\Servers; use Carbon\CarbonImmutable; -use Illuminate\Http\Response; use Pterodactyl\Models\Server; use Illuminate\Http\JsonResponse; use Pterodactyl\Models\Permission; use Pterodactyl\Services\Nodes\NodeJWTService; -use Symfony\Component\HttpKernel\Exception\HttpException; +use Pterodactyl\Exceptions\Http\HttpForbiddenException; use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest; use Pterodactyl\Services\Servers\GetUserPermissionsService; use Pterodactyl\Http\Controllers\Api\Client\ClientApiController; @@ -55,26 +54,22 @@ class WebsocketController extends ClientApiController { $user = $request->user(); if ($user->cannot(Permission::ACTION_WEBSOCKET_CONNECT, $server)) { - throw new HttpException(Response::HTTP_FORBIDDEN, 'You do not have permission to connect to this server\'s websocket.'); + throw new HttpForbiddenException('You do not have permission to connect to this server\'s websocket.'); } $permissions = $this->permissionsService->handle($server, $user); - $node = null; + $node = $server->node; if (! is_null($server->transfer)) { // Check if the user has permissions to receive transfer logs. if (! in_array('admin.websocket.transfer', $permissions)) { - throw new HttpException(Response::HTTP_FORBIDDEN, 'You do not have permission to view transfer logs'); + throw new HttpForbiddenException('You do not have permission to view server transfer logs.'); } // Redirect the websocket request to the new node if the server has been archived. if ($server->transfer->archived) { $node = $server->transfer->newNode; - } else { - $node = $server->node; } - } else { - $node = $server->node; } $token = $this->jwtService