/**
  * @param User $user
  * @param AuthenticationResult $result
  */
 public function updateUserFromAuthenticationResult(User $user, AuthenticationResult $result)
 {
     foreach ($user->getTokens() as $token) {
         if ($token->getService() == $result->getService()) {
             if ($token->getToken()->toArray() != $result->getCredentials()) {
                 $user->getTokens()->removeElement($token);
             } else {
                 return;
             }
         }
     }
     $token = new User\Token();
     $token->setService($result->getService());
     $token->setToken(new Hash($result->getCredentials()));
     $user->addToken($token);
 }
Esempio n. 2
0
 /**
  * @param Token $token
  * @return $this
  */
 public function addToken(Token $token)
 {
     $token->setUser($this);
     $this->tokens->add($token);
     return $this;
 }