1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 19:14:03 +00:00

Create PreventAccessFromTenants.php

This commit is contained in:
Robert Dennis 2020-12-01 06:46:36 +00:00 committed by GitHub
parent 30a1f9102d
commit 65c30aaa1f

View file

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