Skip to content

Commit

Permalink
Add GuestTenantMiddleware and improve Unauthenticated handling (#15)
Browse files Browse the repository at this point in the history
* restructure readme

* update dependencies & add setup() void return types

* extend Laravel's authenticate middleware to easily redirect users to a login page instead of showing a 403 error.

* provide a config value to change the redirect route

* remove unused import

* add guest tenant middleware

* add GuestTenantMiddleware to Readme
  • Loading branch information
Naoray authored and bradenkeith committed Apr 9, 2019
1 parent fab709a commit 7ece10f
Show file tree
Hide file tree
Showing 9 changed files with 608 additions and 987 deletions.
27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Any resources saved while accessing a scoped subdomain will automatically be sav
- [Installation](#installation)
- [Usage](#usage)
- [Middleware](#middleware)
- [Authenticated](#authenticated)
- [Guest Tenant](#guest-tenant)
- [Tenant Assignment for Models](#tenant-assignment-for-models)
- [Providing Access to Admin Domain](#providing-access-to-admin-domain)
- [Console Commands](#console-commands)
Expand Down Expand Up @@ -105,19 +107,38 @@ Tenant::first()->users()->save($user);

### Middleware

This package comes with `TenantMiddleware` middleware. You can add it inside your `app/Http/Kernel.php` file.
#### Authenticated
This package comes with `TenantMiddleware` middleware which extends Laravel's `Illuminate\Auth\Middleware\Authenticate`. You can add it inside your `app/Http/Kernel.php` file.

```php
protected $routeMiddleware = [
// ...
'tenant' => \RomegaDigital\Multitenancy\Middleware\TenantMiddleware::class,
'tenant.auth' => \RomegaDigital\Multitenancy\Middleware\TenantMiddleware::class,
];
```

Then you can bring multitenancy to your routes using middleware rules:

```php
Route::group(['middleware' => ['tenant']], function () {
Route::group(['middleware' => ['tenant.auth']], function () {
// ...
});
```

#### Guest Tenant
This package comes with `GuestTenantMiddleware` middleware which applies the tenant scope to all models and can be used for allowing guest users to access Tenant related pages. You can add it inside your `app/Http/Kernel.php` file.

```php
protected $routeMiddleware = [
// ...
'tenant.guest' => \RomegaDigital\Multitenancy\Middleware\GuestTenantMiddleware::class,
];
```

Then you can bring multitenancy to your routes using middleware rules:

```php
Route::group(['middleware' => ['tenant.guest']], function () {
// ...
});
```
Expand Down
Loading

0 comments on commit 7ece10f

Please sign in to comment.