mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 13:54:04 +00:00
wip
This commit is contained in:
parent
e7aefe6c09
commit
adc1b5e73e
2 changed files with 14 additions and 5 deletions
|
|
@ -28,11 +28,13 @@ class InitializeTenancy
|
||||||
*/
|
*/
|
||||||
public function handle($request, Closure $next)
|
public function handle($request, Closure $next)
|
||||||
{
|
{
|
||||||
|
if (! in_array($request->getHost(), config('tenancy.exempt_domains', []), true)) {
|
||||||
try {
|
try {
|
||||||
tenancy()->init($request->getHost());
|
tenancy()->init($request->getHost());
|
||||||
} catch (TenantCouldNotBeIdentifiedException $e) {
|
} catch (TenantCouldNotBeIdentifiedException $e) {
|
||||||
($this->onFail)($e);
|
($this->onFail)($e);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,10 @@ declare(strict_types=1);
|
||||||
namespace Stancl\Tenancy;
|
namespace Stancl\Tenancy;
|
||||||
|
|
||||||
use Illuminate\Cache\CacheManager;
|
use Illuminate\Cache\CacheManager;
|
||||||
|
use Illuminate\Contracts\Http\Kernel;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Stancl\Tenancy\Middleware\PreventAccessFromTenantDomains;
|
||||||
use Stancl\Tenancy\TenancyBootstrappers\FilesystemTenancyBootstrapper;
|
use Stancl\Tenancy\TenancyBootstrappers\FilesystemTenancyBootstrapper;
|
||||||
|
|
||||||
class TenancyServiceProvider extends ServiceProvider
|
class TenancyServiceProvider extends ServiceProvider
|
||||||
|
|
@ -79,8 +81,13 @@ class TenancyServiceProvider extends ServiceProvider
|
||||||
|
|
||||||
$this->loadRoutesFrom(__DIR__ . '/routes.php');
|
$this->loadRoutesFrom(__DIR__ . '/routes.php');
|
||||||
|
|
||||||
|
$this->app->make(Kernel::class)->prependMiddleware([
|
||||||
|
Middleware\InitializeTenancy::class,
|
||||||
|
]);
|
||||||
|
|
||||||
Route::middlewareGroup('tenancy', [
|
Route::middlewareGroup('tenancy', [
|
||||||
\Stancl\Tenancy\Middleware\InitializeTenancy::class,
|
/** Prevent access from tenant domains to central routes and vice versa. */
|
||||||
|
Middleware\PreventAccessFromTenantDomains::class,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->app->singleton('globalUrl', function ($app) {
|
$this->app->singleton('globalUrl', function ($app) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue