/** * Create a 'remote' provider record from a session stored 'transitional' one. * * @param string $guid * * @return Storage\Entity\Provider */ protected function convertTransitionalProviderToEntity($guid) { $provider = $this->session->getTransitionalProvider()->getProviderEntity(); $provider->setGuid($guid); $provider->setLastupdate(Carbon::now()); $this->records->saveProvider($provider); $this->session->removeTransitionalProvider(); return $provider; }
/** * . * * @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; }