/** * {@inheritdoc} */ public function authenticate(TokenInterface $token) { if (!($payload = $this->jwtManager->decode($token))) { throw new AuthenticationException('Invalid JWT Token'); } $user = $this->getUserFromPayload($payload); $authToken = new JWTUserToken($user->getRoles()); $authToken->setUser($user); $authToken->setRawToken($token->getCredentials()); $event = new JWTAuthenticatedEvent($payload, $authToken); $this->dispatcher->dispatch(Events::JWT_AUTHENTICATED, $event); return $authToken; }