mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 19:14:03 +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:
parent
1a5300ab4f
commit
577af9ac9c
1 changed files with 31 additions and 0 deletions
31
src/Middleware/AccessFromCentralDomains.php
Normal file
31
src/Middleware/AccessFromCentralDomains.php
Normal 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);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue