2018-05-04 13:02:51 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Http\Middleware;
|
|
|
|
|
|
|
|
use Closure;
|
2022-10-14 16:59:20 +00:00
|
|
|
use Illuminate\Http\Request;
|
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
|
|
|
/**
|
|
|
|
* MaintenanceMiddleware constructor.
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function __construct(private ResponseFactory $response)
|
2018-05-26 18:00:28 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-05-04 13:02:51 +00:00
|
|
|
/**
|
|
|
|
* Handle an incoming request.
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function handle(Request $request, Closure $next): mixed
|
2018-05-04 13:02:51 +00:00
|
|
|
{
|
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);
|
|
|
|
}
|
|
|
|
}
|