Exemplo n.º 1
0
 /**
  * @param AuthenticationResult $authResult
  * @return User
  */
 public function createFromAuthenticationResult(AuthenticationResult $authResult)
 {
     $user = new User();
     $user->setAlias($authResult->getAlias());
     $user->setFullName($authResult->getName());
     foreach ($authResult->getEmails() as $email) {
         $user->addEmail((new User\Email())->setEmail($email));
     }
     $user->addToken((new User\Token())->setService($authResult->getService())->setToken(new Hash($authResult->getCredentials())));
     $generator = new KeyGenerator();
     $key = $generator->generateKey();
     $user->setPublicKey($key->getPublic());
     $user->setPrivateKey($key->getPrivate());
     return $user;
 }