2015-12-06 18:58:49 +00:00
|
|
|
<?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');
|
|
|
|
}
|
|
|
|
|
2016-01-04 21:09:39 +00:00
|
|
|
$server = Server::getByUUID($request->route()->server);
|
|
|
|
if (!$server) {
|
|
|
|
return redirect()->route('index');
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($server->installed !== 1) {
|
|
|
|
return response()->view('errors.installing', [], 503);
|
2015-12-06 18:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return $next($request);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|