mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-15 16:44:04 +00:00
* Test on Laravel 9 * Don't extend final Kernel class * Make FilesystemTenancyBootstrapper compatible with Flysystem v3 Co-authored-by: George <jiri.zizka@funfirst.cz> * Update tenant maintenance mode te be in line with Laravel * Exclude PHP 7.4 <> L9 combination from testing * add root_override-related assertions * getPrefix -> getPathPrefix * handle / inconsistency in s3 prefix * Refactor Storage facade changes Co-authored-by: George <jiri.zizka@funfirst.cz> Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Stancl\Tenancy\Middleware;
|
|
|
|
use Closure;
|
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
|
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode;
|
|
use Stancl\Tenancy\Exceptions\TenancyNotInitializedException;
|
|
use Symfony\Component\HttpFoundation\IpUtils;
|
|
|
|
class CheckTenantForMaintenanceMode extends CheckForMaintenanceMode
|
|
{
|
|
public function handle($request, Closure $next)
|
|
{
|
|
if (! tenant()) {
|
|
throw new TenancyNotInitializedException;
|
|
}
|
|
|
|
if (tenant('maintenance_mode')) {
|
|
$data = tenant('maintenance_mode');
|
|
|
|
if (isset($data['allowed']) && IpUtils::checkIp($request->ip(), (array) $data['allowed'])) {
|
|
return $next($request);
|
|
}
|
|
|
|
if ($this->inExceptArray($request)) {
|
|
return $next($request);
|
|
}
|
|
|
|
throw new HttpException(
|
|
503,
|
|
'Service Unavailable',
|
|
null,
|
|
isset($data['retry']) ? ['Retry-After' => $data['retry']] : []
|
|
);
|
|
}
|
|
|
|
return $next($request);
|
|
}
|
|
}
|