1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 19:34:04 +00:00

PreventAccessFromCentralDomains middleware

This commit is contained in:
Samuel Štancl 2020-05-16 11:57:29 +02:00
parent 7a7200fd25
commit 3547b8ce4c

View file

@ -0,0 +1,29 @@
<?php
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);
}
}