| @@ 247-267 (lines=21) @@ | ||
| 244 | * |
|
| 245 | * @return void |
|
| 246 | */ |
|
| 247 | public function logout() |
|
| 248 | { |
|
| 249 | if (!$token = $this->getBearerToken()) { |
|
| 250 | return; |
|
| 251 | } |
|
| 252 | ||
| 253 | try { |
|
| 254 | $this->jwtService->invalidateToken($token); |
|
| 255 | } catch (Exception $e) { } |
|
| 256 | ||
| 257 | if (isset($this->events)) { |
|
| 258 | $this->events->fire(new Logout($this->user)); |
|
| 259 | } |
|
| 260 | ||
| 261 | // Once we have fired the logout event we will clear the users out of memory |
|
| 262 | // so they are no longer available as the user is no longer considered as |
|
| 263 | // being signed into this application and should not be available here. |
|
| 264 | $this->user = null; |
|
| 265 | $this->token = null; |
|
| 266 | $this->loggedOut = true; |
|
| 267 | } |
|
| 268 | ||
| 269 | /** |
|
| 270 | * log this user out from every token |
|
| @@ 274-297 (lines=24) @@ | ||
| 271 | * |
|
| 272 | * @return void |
|
| 273 | */ |
|
| 274 | public function logoutAll() |
|
| 275 | { |
|
| 276 | if (!$token = $this->getBearerToken()) { |
|
| 277 | return; |
|
| 278 | } |
|
| 279 | ||
| 280 | try { |
|
| 281 | $user = $this->getUserByToken($token); |
|
| 282 | ||
| 283 | $this->jwtService->wipeUserTokens($user); |
|
| 284 | ||
| 285 | } catch (Exception $e) { } |
|
| 286 | ||
| 287 | if (isset($this->events)) { |
|
| 288 | $this->events->fire(new Logout($this->user)); |
|
| 289 | } |
|
| 290 | ||
| 291 | // Once we have fired the logout event we will clear the users out of memory |
|
| 292 | // so they are no longer available as the user is no longer considered as |
|
| 293 | // being signed into this application and should not be available here. |
|
| 294 | $this->user = null; |
|
| 295 | $this->token = null; |
|
| 296 | $this->loggedOut = true; |
|
| 297 | } |
|
| 298 | ||
| 299 | /** |
|
| 300 | * Refresh user token |
|