@@ 274-294 (lines=21) @@ | ||
271 | * |
|
272 | * @return void |
|
273 | */ |
|
274 | public function logout() |
|
275 | { |
|
276 | if (!$token = $this->getBearerToken()) { |
|
277 | return; |
|
278 | } |
|
279 | ||
280 | try { |
|
281 | $this->jwtService->invalidateToken($token); |
|
282 | } catch (Exception $e) { } |
|
283 | ||
284 | if (isset($this->events)) { |
|
285 | $this->events->fire(new Logout($this->user)); |
|
286 | } |
|
287 | ||
288 | // Once we have fired the logout event we will clear the users out of memory |
|
289 | // so they are no longer available as the user is no longer considered as |
|
290 | // being signed into this application and should not be available here. |
|
291 | $this->user = null; |
|
292 | $this->token = null; |
|
293 | $this->loggedOut = true; |
|
294 | } |
|
295 | ||
296 | /** |
|
297 | * log this user out from every token |
|
@@ 301-324 (lines=24) @@ | ||
298 | * |
|
299 | * @return void |
|
300 | */ |
|
301 | public function logoutAll() |
|
302 | { |
|
303 | if (!$token = $this->getBearerToken()) { |
|
304 | return; |
|
305 | } |
|
306 | ||
307 | try { |
|
308 | $user = $this->jwtService->getClaimFromToken($token); |
|
309 | ||
310 | $this->jwtService->wipeUserTokens($user); |
|
311 | ||
312 | } catch (Exception $e) { } |
|
313 | ||
314 | if (isset($this->events)) { |
|
315 | $this->events->fire(new Logout($this->user)); |
|
316 | } |
|
317 | ||
318 | // Once we have fired the logout event we will clear the users out of memory |
|
319 | // so they are no longer available as the user is no longer considered as |
|
320 | // being signed into this application and should not be available here. |
|
321 | $this->user = null; |
|
322 | $this->token = null; |
|
323 | $this->loggedOut = true; |
|
324 | } |
|
325 | ||
326 | /** |
|
327 | * Refresh user token |