public function loadUserByOAuthUserResponse(UserResponseInterface $response)
 {
     try {
         $user = $this->fosService->loadUserByUsername($response->getUsername());
     } catch (UsernameNotFoundException $e) {
         $user = $this->createNewUser($response->getUsername(), $response->getEmail(), $response);
     }
     return $user;
 }
 /**
  * @param SecurityUserInterface $user
  *
  * @return SecurityUserInterface
  * @throws UnsupportedUserException
  */
 public function refreshUser(SecurityUserInterface $user)
 {
     if ($this->stateless) {
         throw new UnsupportedUserException();
     }
     return parent::refreshUser($user);
 }
 /**
  * @expectedException \Symfony\Component\Security\Core\Exception\UnsupportedUserException
  */
 public function testRefreshInvalidUser()
 {
     $user = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface');
     $this->userProvider->refreshUser($user);
 }