2018-05-04 13:02:51 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Http\Middleware;
|
|
|
|
|
|
|
|
use Closure;
|
2018-05-26 18:00:28 +00:00
|
|
|
use Illuminate\Contracts\Routing\ResponseFactory;
|
2018-05-04 13:02:51 +00:00
|
|
|
|
|
|
|
class MaintenanceMiddleware
|
|
|
|
{
|
2018-05-26 18:00:28 +00:00
|
|
|
/**
|
|
|
|
* @var \Illuminate\Contracts\Routing\ResponseFactory
|
|
|
|
*/
|
|
|
|
private $response;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* MaintenanceMiddleware constructor.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Contracts\Routing\ResponseFactory $response
|
|
|
|
*/
|
|
|
|
public function __construct(ResponseFactory $response)
|
|
|
|
{
|
|
|
|
$this->response = $response;
|
|
|
|
}
|
|
|
|
|
2018-05-04 13:02:51 +00:00
|
|
|
/**
|
|
|
|
* Handle an incoming request.
|
|
|
|
*
|
2018-05-26 18:00:28 +00:00
|
|
|
* @param \Illuminate\Http\Request $request
|
2019-09-06 04:32:57 +00:00
|
|
|
* @param \Closure $next
|
2018-05-04 13:02:51 +00:00
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function handle($request, Closure $next)
|
|
|
|
{
|
2018-05-26 18:00:28 +00:00
|
|
|
/** @var \Pterodactyl\Models\Server $server */
|
2018-05-04 13:02:51 +00:00
|
|
|
$server = $request->attributes->get('server');
|
2018-05-26 18:00:28 +00:00
|
|
|
$node = $server->getRelation('node');
|
2018-05-04 13:02:51 +00:00
|
|
|
|
2018-05-31 14:34:35 +00:00
|
|
|
if ($node->maintenance_mode) {
|
2018-05-26 18:00:28 +00:00
|
|
|
return $this->response->view('errors.maintenance');
|
2018-05-04 13:02:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return $next($request);
|
|
|
|
}
|
|
|
|
}
|