Esempio n. 1
0
 /**
  * {@inheritDoc}
  */
 public function connect(UserInterface $user, UserResponseInterface $response)
 {
     $username = $response->getNickname();
     $twitterId = $response->getUsername();
     $accessToken = $response->getAccessToken();
     $secretToken = $response->getTokenSecret();
     //we "disconnect" previously connected users
     $previousUser = $this->userManager->findUserByUsername($username);
     if (!is_null($previousUser)) {
         $previousUser->setTwitterId(null);
         $previousUser->setAccessToken(null);
         $previousUser->setSecretToken(null);
         $this->userManager->updateUser($previousUser);
     }
     //we connect current user
     $user->setTwitterId($twitterId);
     $user->setAccessToken($accessToken);
     $user->setSecretToken($secretToken);
     $this->userManager->updateUser($user);
 }