mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-04 20:54:03 +00:00
PreventAccessFromTenantDomains middleware
This commit is contained in:
parent
24f8e10c1b
commit
2381bf1e01
1 changed files with 27 additions and 0 deletions
27
src/Middleware/PreventAccessFromTenantDomains.php
Normal file
27
src/Middleware/PreventAccessFromTenantDomains.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Stancl\Tenancy\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
|
||||||
|
class PreventAccessFromTenantDomains
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure $next
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle($request, Closure $next)
|
||||||
|
{
|
||||||
|
// If the domain is not in exempt domains, it's a tenant domain.
|
||||||
|
// Tenant domains can't have routes without tenancy middleware.
|
||||||
|
if (! in_array(request()->getHost(), config('tenancy.exempt_domains')) &&
|
||||||
|
! in_array('tenancy', request()->route()->middleware())) {
|
||||||
|
abort(404);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue