예제 #1
0
 /**
  * Create and store the account record.
  *
  * @param Profile $entity
  *
  * @return Storage\Entity\Account
  */
 protected function createAccount(Profile $entity)
 {
     $displayName = $entity->getDisplayname();
     $emailAddress = $entity->getEmail();
     $account = $this->records->createAccount($displayName, $emailAddress, $this->config->getRolesRegister());
     $this->records->saveAccount($account);
     return $account;
 }
예제 #2
0
 /**
  * .
  *
  * @param string                 $providerName
  * @param AccessToken            $accessToken
  * @param ResourceOwnerInterface $resourceOwner
  */
 protected function setSessionNewProvider($providerName, AccessToken $accessToken, ResourceOwnerInterface $resourceOwner)
 {
     if ($this->session->hasAuthorisation()) {
         // Member is already in possession of another login, and the provider does NOT exist
         $this->createProviderTransition($accessToken, $resourceOwner);
         return;
     }
     $account = $this->records->getAccountByEmail($resourceOwner->getEmail());
     if ($account === false) {
         $account = $this->records->createAccount($resourceOwner->getName(), $resourceOwner->getEmail(), $this->config->getRolesRegister());
     }
     $providerEntity = new Entity\Provider();
     $providerEntity->setGuid($account->getGuid());
     $providerEntity->setProvider($providerName);
     $providerEntity->setResourceOwner($resourceOwner);
     $providerEntity->setResourceOwnerId($resourceOwner->getId());
     $providerEntity->setLastupdate(Carbon::now());
     $this->records->saveProvider($providerEntity);
     $this->session->addAccessToken($providerName, $accessToken)->createAuthorisation($providerEntity->getGuid());
     $this->providerEntity = $providerEntity;
 }