mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 18:44:03 +00:00
PreventAccessFromCentralDomains middleware
This commit is contained in:
parent
7a7200fd25
commit
3547b8ce4c
1 changed files with 29 additions and 0 deletions
29
src/Middleware/PreventAccessFromCentralDomains.php
Normal file
29
src/Middleware/PreventAccessFromCentralDomains.php
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue