@@ 300-325 (lines=26) @@ | ||
297 | * |
|
298 | * @return void |
|
299 | */ |
|
300 | public function logout() |
|
301 | { |
|
302 | if (!$token = $this->getBearerToken()) { |
|
303 | return; |
|
304 | } |
|
305 | ||
306 | try { |
|
307 | $payload = $this->getPayloadOfToken($token); |
|
308 | ||
309 | if ($user = $this->getUserByPayload($payload)) { |
|
310 | $this->tokenManager->remove($user->getAuthIdentifier(), $payload['jti']); |
|
311 | } |
|
312 | ||
313 | } catch (TokenMismatchException $e) { } |
|
314 | ||
315 | if (isset($this->events)) { |
|
316 | $this->events->fire(new Logout($this->user)); |
|
317 | } |
|
318 | ||
319 | // Once we have fired the logout event we will clear the users out of memory |
|
320 | // so they are no longer available as the user is no longer considered as |
|
321 | // being signed into this application and should not be available here. |
|
322 | $this->user = null; |
|
323 | $this->token = null; |
|
324 | $this->loggedOut = true; |
|
325 | } |
|
326 | ||
327 | /** |
|
328 | * log this user out from every token |
|
@@ 332-357 (lines=26) @@ | ||
329 | * |
|
330 | * @return void |
|
331 | */ |
|
332 | public function logoutAll() |
|
333 | { |
|
334 | if (!$token = $this->getBearerToken()) { |
|
335 | return; |
|
336 | } |
|
337 | ||
338 | try { |
|
339 | $payload = $this->getPayloadOfToken($token); |
|
340 | ||
341 | if ($user = $this->getUserByPayload($payload)) { |
|
342 | $this->tokenManager->removeAll($user->getAuthIdentifier()); |
|
343 | } |
|
344 | ||
345 | } catch (TokenMismatchException $e) { } |
|
346 | ||
347 | if (isset($this->events)) { |
|
348 | $this->events->fire(new Logout($this->user)); |
|
349 | } |
|
350 | ||
351 | // Once we have fired the logout event we will clear the users out of memory |
|
352 | // so they are no longer available as the user is no longer considered as |
|
353 | // being signed into this application and should not be available here. |
|
354 | $this->user = null; |
|
355 | $this->token = null; |
|
356 | $this->loggedOut = true; |
|
357 | } |
|
358 | ||
359 | /** |
|
360 | * Refresh user token |