Path: blob/1.0-develop/app/Http/Middleware/Admin/Servers/ServerInstalled.php
10284 views
<?php12namespace Pterodactyl\Http\Middleware\Admin\Servers;34use Illuminate\Http\Request;5use Illuminate\Http\Response;6use Pterodactyl\Models\Server;7use Symfony\Component\HttpKernel\Exception\HttpException;8use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;910class ServerInstalled11{12/**13* Checks that the server is installed before allowing access through the route.14*/15public function handle(Request $request, \Closure $next): mixed16{17/** @var Server|null $server */18$server = $request->route()->parameter('server');1920if (!$server instanceof Server) {21throw new NotFoundHttpException('No server resource was located in the request parameters.');22}2324if (!$server->isInstalled()) {25throw new HttpException(Response::HTTP_FORBIDDEN, 'Access to this resource is not allowed due to the current installation state.');26}2728return $next($request);29}30}313233