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