mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-06 02:04:04 +00:00
31 lines
668 B
PHP
31 lines
668 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Stancl\Tenancy\Middleware;
|
|
|
|
use Closure;
|
|
use Illuminate\Http\Request;
|
|
|
|
class PreventAccessFromCentralDomains
|
|
{
|
|
/**
|
|
* Set this property if you want to customize the on-fail behavior.
|
|
*
|
|
* @var callable|null
|
|
*/
|
|
public static $abortRequest;
|
|
|
|
public function handle(Request $request, Closure $next)
|
|
{
|
|
if (in_array($request->getHost(), config('tenancy.central_domains'))) {
|
|
$abortRequest = static::$abortRequest ?? function () {
|
|
abort(404);
|
|
};
|
|
|
|
return $abortRequest($request, $next);
|
|
}
|
|
|
|
return $next($request);
|
|
}
|
|
}
|