예제 #1
0
파일: Transition.php 프로젝트: bolt/Members
 /**
  * Constructor.
  *
  * @param string                 $guid
  * @param string                 $providerName
  * @param AccessToken            $accessToken
  * @param ResourceOwnerInterface $resourceOwner
  */
 public function __construct($guid, $providerName, AccessToken $accessToken, ResourceOwnerInterface $resourceOwner)
 {
     if (Uuid::isValid($guid) === false) {
         throw new \RuntimeException('Tried to create Transition object with an invalid GUID.');
     }
     $this->guid = $guid;
     $this->accessToken = $accessToken;
     $this->resourceOwner = $resourceOwner;
     $providerEntity = new Entity\Provider();
     $providerEntity->setProvider($providerName);
     $providerEntity->setRefreshToken($accessToken->getRefreshToken());
     $providerEntity->setResourceOwnerId($resourceOwner->getId());
     $providerEntity->setResourceOwner($resourceOwner);
     $this->providerEntity = $providerEntity;
 }
예제 #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;
 }