1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 18:34:04 +00:00

Create AccessFromCentralDomains.php

add middleware run only central domain . invert PreventAccessFromCentralDomains  . i have module cms we need run cms route only in central domain
This commit is contained in:
webactor724 2021-06-30 16:16:15 +04:30 committed by GitHub
parent 1a5300ab4f
commit 577af9ac9c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace Stancl\Tenancy\Middleware;
use Closure;
use Illuminate\Http\Request;
class AccessFromCentralDomains
{
/**
* 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);
}
}