misc_pterodactyl-panel/app/Http/Middleware/CheckServer.php

39 lines
765 B
PHP
Raw Normal View History

<?php
namespace Pterodactyl\Http\Middleware;
use Closure;
use Auth;
use Pterodactyl\Models\Server;
use Debugbar;
class CheckServer
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!Auth::user()) {
return redirect()->guest('auth/login');
}
$server = Server::getByUUID($request->route()->server);
if (!$server) {
2016-01-09 01:39:16 +00:00
return response()->view('errors.403', [], 403);
}
if ($server->installed !== 1) {
return response()->view('errors.installing', [], 503);
}
return $next($request);
}
}