Skip to content

Commit

Permalink
fire tenantIdentified event
Browse files Browse the repository at this point in the history
  • Loading branch information
secmohammed authored Jun 27, 2019
1 parent b41d456 commit 4896b6a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Tenant/Middleware/SetTenant.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

namespace Artify\Artify\Tenant\Middleware;
use Artify\Artify\Contracts\Models\Tenant;

use Artify\Artify\Contracts\Models\Tenant;
use Artify\Artify\Tenant\Events\TenantIdentified;
use Closure;
use Illuminate\Auth\AuthenticationException;

Expand All @@ -17,6 +18,7 @@ class SetTenant
*/
public function handle($request, Closure $next)
{

optional($this->resolveTenant(session('tenant')), function ($tenant) {
if (!auth()->user()->{str_plural(app(Tenant::class)->getTable())}->contains('id', $tenant->id)) {
throw new AuthenticationException(
Expand All @@ -25,6 +27,7 @@ public function handle($request, Closure $next)
$this->redirectTo($request)
);
}
event(new TenantIdentified($tenant));
});

return $next($request);
Expand Down

0 comments on commit 4896b6a

Please sign in to comment.