Skip to content

Commit 749262c

Browse files
authored
Merge pull request #98 from neemiasjr/feat/events
feat(auth-events): Triggers events to authenticated user and logout u…
2 parents 9107870 + 121f9b9 commit 749262c

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/Auth/Guard/KeycloakWebGuard.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
namespace Vizir\KeycloakWebGuard\Auth\Guard;
44

5+
use Illuminate\Auth\Events\Authenticated;
56
use Illuminate\Contracts\Auth\Authenticatable;
67
use Illuminate\Contracts\Auth\Guard;
78
use Illuminate\Http\Request;
9+
use Illuminate\Support\Facades\Auth;
810
use Illuminate\Support\Facades\Config;
911
use Vizir\KeycloakWebGuard\Auth\KeycloakAccessToken;
1012
use Vizir\KeycloakWebGuard\Exceptions\KeycloakCallbackException;
@@ -162,6 +164,8 @@ public function authenticate()
162164
$user = $this->provider->retrieveByCredentials($user);
163165
$this->setUser($user);
164166

167+
event(new Authenticated(Auth::getDefaultDriver(), Auth()->user()));
168+
165169
return true;
166170
}
167171

src/Controllers/AuthController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Vizir\KeycloakWebGuard\Controllers;
44

5+
use Illuminate\Auth\Events\Logout;
56
use Illuminate\Http\RedirectResponse;
67
use Illuminate\Http\Request;
78
use Illuminate\Routing\Controller;
@@ -33,6 +34,9 @@ public function logout()
3334
{
3435
$url = KeycloakWeb::getLogoutUrl();
3536
KeycloakWeb::forgetToken();
37+
38+
event(new Logout(Auth::getDefaultDriver(), Auth()->user()));
39+
3640
return redirect($url);
3741
}
3842

0 commit comments

Comments
 (0)