/** * Save a profile registration form. * * @param Profile $entity * @param Form $form * @param AbstractProvider $provider * @param string $providerName * * @return FormEntityHandler */ public function saveProfileRegisterForm(Profile $entity, Form $form, AbstractProvider $provider, $providerName) { // Create and store the account record $account = $this->createAccount($entity); $guid = $account->getGuid(); // Create the event $event = new MembersProfileEvent($account); // Create verification meta $this->createAccountVerificationKey($event, $guid); // Create a local OAuth account record $password = $form->get('password')->getData(); if ($password) { $this->createLocalOauthAccount($guid, $password); $this->createLocalProviderEntity($guid); } // Create a provider entry if ($this->session->isTransitional()) { $accessToken = $this->session->getTransitionalProvider()->getAccessToken(); $this->convertTransitionalProviderToEntity($guid); } else { $accessToken = $provider->getAccessToken('password', ['guid' => $account->getGuid()]); } // Set up the initial session. $this->session->addAccessToken($providerName, $accessToken)->createAuthorisation($guid); // Dispatch the account profile post-save event $this->eventDispatcher->dispatch(MembersEvents::MEMBER_PROFILE_REGISTER, $event); return $this; }
/** * Create a new provider entity object. * * @param AccessToken $accessToken * @param ResourceOwnerInterface $resourceOwner */ protected function createProviderTransition(AccessToken $accessToken, ResourceOwnerInterface $resourceOwner) { // Create a new provider entry $providerName = $this->providerManager->getProviderName(); // If we have an authorisation, this is for an existing and logged in account, // else we either have a new registration or one we need to find an associate. $guid = $this->session->getAuthorisation()->getGuid(); $transition = new Transition($guid, $providerName, $accessToken, $resourceOwner); $this->session->addAccessToken($providerName, $accessToken)->setTransitionalProvider($transition); $this->setDebugMessage(sprintf('Creating provider profile for %s ID %s', $providerName, $resourceOwner->getId())); $this->setDebugMessage(sprintf('Creating provisional %s provider entity for access token %s for ID %s', $providerName, $accessToken, $resourceOwner->getId())); }