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

33 lines
731 B
PHP
Raw Normal View History

2018-05-04 13:02:51 +00:00
<?php
namespace Pterodactyl\Http\Middleware;
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.
*/
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-11-29 17:53:59 +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
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);
}
}