Beispiel #1
0
 /**
  * Create or update user by using data from facebook and login to store
  *
  * @param GraphUser   $facebookUser
  * @param AccessToken $accessToken
  *
  * @return CustomerInterface
  */
 private function createOrUpdateAndLogin(GraphUser $facebookUser, AccessToken $accessToken)
 {
     if (!$this->customer->getId()) {
         $this->customer->setEmail($facebookUser->getEmail());
         $this->customer->setFirstname($facebookUser->getFirstName());
         $this->customer->setLastname($facebookUser->getLastName());
         $this->customer->setMiddlename($facebookUser->getMiddleName());
         $this->customer->setGender((int) ($facebookUser->getGender() == 'male'));
     }
     $this->customer->setCustomAttribute('sf_id', $facebookUser->getId());
     $this->customer->setCustomAttribute('sf_access_token', serialize($accessToken));
     if ($this->customer->getId()) {
         $customer = $this->customerRepository->save($this->customer);
     } else {
         $customer = $this->accountManagement->createAccount($this->customer);
     }
     $this->login($customer->getId());
     return $customer;
 }
Beispiel #2
0
 /**
  * Get the Facebook account middle name
  *
  * @return string
  */
 public function getMiddleName()
 {
     return $this->graphuser->getMiddleName();
 }