/**
  * @return JsonResponse
  */
 public function getUser()
 {
     $user = null;
     $minimalUserInfo = $this->userSessionService->getMinimalUserInfo();
     if (is_null($minimalUserInfo)) {
         return new Response('No active user.', Response::HTTP_NOT_FOUND);
     }
     $user = $this->userService->getUser($minimalUserInfo->getId());
     return JsonResponse::create()->setData($user)->setPrivate();
 }
 /**
  * @inheritdoc
  */
 public function authenticate(TokenInterface $token)
 {
     $userId = $token->getUser();
     $user = $this->userService->getUser($userId);
     if (is_null($user)) {
         throw new AuthenticationException(sprintf('User with id %s does not exist.', $userId));
     }
     $token = new UiTIDToken($user->getRoles());
     $token->setUser($user);
     return $token;
 }