/**
  * Refreshes the user for the account interface.
  *
  * It is up to the implementation to decide if the user data should be
  * totally reloaded (e.g. from the database), or if the UserInterface
  * object can just be merged into some internal array of users / identity
  * map.
  *
  * @param UserInterface $user
  *
  * @return UserInterface
  *
  * @throws UnsupportedUserException if the account is not supported
  */
 public function refreshUser(UserInterface $user)
 {
     if (!$this->supportsClass(get_class($user))) {
         throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user)));
     }
     /** @var $user User */
     return $this->userRepository->find($user->getId());
 }
 /**
  * Return a UserInterface object based on the credentials.
  *
  * The *credentials* are the return value from getCredentials()
  *
  * You may throw an AuthenticationException if you wish. If you return
  * null, then a UsernameNotFoundException is thrown for you.
  *
  * @param mixed $credentials
  * @param UserProviderInterface $userProvider
  *
  * @throws AuthenticationException
  *
  * @return UserInterface|null
  */
 public function getUser($credentials, UserProviderInterface $userProvider)
 {
     $apiKey = $credentials['token'];
     return $this->userRepository->findOneBy(['apiKey' => $apiKey]);
 }