当前位置: 首页>>代码示例>>PHP>>正文


PHP UserResponseInterface::getFirstName方法代码示例

本文整理汇总了PHP中HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface::getFirstName方法的典型用法代码示例。如果您正苦于以下问题:PHP UserResponseInterface::getFirstName方法的具体用法?PHP UserResponseInterface::getFirstName怎么用?PHP UserResponseInterface::getFirstName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface的用法示例。


在下文中一共展示了UserResponseInterface::getFirstName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loadUserByOAuthUserResponse

 /**
  * @inheritdoc
  */
 public function loadUserByOAuthUserResponse(UserResponseInterface $response)
 {
     try {
         $user = $this->userManager->findUser($response->getEmail());
     } catch (\Exception $e) {
         $username = $response->getEmail();
         $firstName = $response->getFirstName() != '' ? $response->getFirstName() : $response->getNickName();
         $lastName = $response->getLastName() != '' ? $response->getLastName() : '';
         try {
             $user = $this->userManager->createNewUser($username, $response->getEmail(), $firstName, $lastName);
         } catch (\Exception $e) {
             throw $e;
         }
     }
     return new User($user);
 }
开发者ID:crevillo,项目名称:ezsocialloginbundle,代码行数:19,代码来源:EzSocialUserProvider.php

示例2: createUserByOAuthUserResponse

 /**
  * @param UserResponseInterface|ResourceResponse $response
  *
  * @return UserInterface
  */
 protected function createUserByOAuthUserResponse(UserResponseInterface $response)
 {
     /** @var DoSUserInterface $user */
     $user = $this->userFactory->createNew();
     /** @var CustomerInterface $customer */
     $customer = $this->customerFactory->createNew();
     // set default values taken from OAuth sign-in provider account
     // todo: check security configuration provide by `fos....username_email`
     if (null === $response->getEmail()) {
         throw new AccountNoEmailException();
     }
     // set default values taken from OAuth sign-in provider account
     if (null !== ($email = $response->getEmail())) {
         $customer->setEmail($email);
     }
     if (!$user->getUsername()) {
         $user->setUsername($response->getEmail() ?: $response->getNickname());
     }
     // set random password to prevent issue with not nullable field & potential security hole
     $user->setPlainPassword(substr(sha1($response->getAccessToken()), 0, 10));
     $user->setDisplayName($response->getNickname());
     $user->setLocale($response->getLocale());
     $user->setCustomer($customer);
     $user->confirmed();
     $customer->setFirstName($response->getFirstName());
     $customer->setLastName($response->getLastName());
     $customer->setGender($response->getGender() ?: CustomerInterface::UNKNOWN_GENDER);
     $customer->setBirthday($response->getBirthday());
     return $this->updateUserByOAuthUserResponse($user, $response);
 }
开发者ID:liverbool,项目名称:dos-user-bundle,代码行数:35,代码来源:UserProvider.php

示例3: loadUserByOAuthUserResponse

 public function loadUserByOAuthUserResponse(UserResponseInterface $response)
 {
     //Data from response
     $email = $response->getEmail();
     $firstname = $response->getFirstName();
     $lastname = $response->getLastName();
     $nickname = $firstname . $lastname;
     //Check if this user already exists in our app DB
     $qb = $this->doctrine->getManager()->createQueryBuilder();
     $qb->select('u')->from('AppBundle:Person', 'u')->where('u.email = :gmail')->setParameter('gmail', $email)->setMaxResults(1);
     $result = $qb->getQuery()->getResult();
     //add to database if doesn't exists
     if (!count($result)) {
         $person = new Person();
         $person->setFirstname($firstname);
         $person->setLastname($lastname);
         $person->setUsername($nickname);
         $person->setEmail($email);
         //$user->setRoles('ROLE_USER');
         //Set some wild random pass since its irrelevant, this is Google login
         $factory = $this->container->get('security.encoder_factory');
         $encoder = $factory->getEncoder($person);
         $password = $encoder->encodePassword(md5(uniqid()), $person->getSalt());
         $person->setPassword($password);
         $em = $this->doctrine->getManager();
         $em->persist($person);
         $em->flush();
     } else {
         $person = $result[0];
     }
     //set id
     $this->session->set('id', $person->getId());
     return $person;
 }
开发者ID:howest-wsde,项目名称:VrijwilligersTool,代码行数:34,代码来源:OAuthProvider.php

示例4: loadUserByOAuthUserResponse

 /**
  * {@inheritdoc}
  */
 public function loadUserByOAuthUserResponse(UserResponseInterface $response)
 {
     $content = $response->getResponse();
     $resourceOwner = $response->getResourceOwner();
     try {
         $user = $this->loadUserByServiceAndId($resourceOwner->getName(), $content['id']);
         return $user;
     } catch (\Exception $e) {
         $name = $response->getRealName();
         $nameArray = explode(' ', $name, 2);
         $firstName = $response->getFirstName();
         $lastName = $response->getLastName();
         if (empty($firstName) || empty($lastName)) {
             if (array_key_exists(0, $nameArray)) {
                 $firstName = ucfirst(strtolower($nameArray[0]));
             }
             if (array_key_exists(1, $nameArray)) {
                 $lastName = ucfirst(strtolower($nameArray[1]));
             }
         }
         $user = array();
         $user['firstName'] = $firstName;
         $user['lastName'] = $lastName;
         $user['username'] = $this->createUsername($response->getNickname());
         $user['mail'] = $response->getEmail();
         $this->session->set('icap.oauth.user', $user);
         $resourceOwnerArray = array('name' => $resourceOwner->getName(), 'id' => $content['id']);
         $this->session->set('icap.oauth.resource_owner', $resourceOwnerArray);
         throw $e;
     }
 }
开发者ID:claroline,项目名称:distribution,代码行数:34,代码来源:OauthUserProvider.php

示例5: loadUserByOAuthUserResponse

 /**
  * Loads the user by a given UserResponseInterface object.
  *
  * @param UserResponseInterface $response
  *
  * @return UserInterface
  *
  * @throws UsernameNotFoundException if the user is not found
  */
 public function loadUserByOAuthUserResponse(UserResponseInterface $response)
 {
     $em = $this->em;
     $type = $response->getResourceOwner()->getName();
     $user = $em->getRepository('AppBundle:User')->findOneBy(['email' => $response->getEmail()]);
     if ($user === null) {
         $user = new User();
         $user->setEmail($response->getEmail())->setFirstName($response->getFirstName() ?: $response->getUsername())->setLastName($response->getLastName() ?: $response->getRealname())->setIsActive(true);
         $em->persist($user);
         $em->flush();
     }
     if ($type === 'facebook') {
         $user->setFacebookToken($response->getAccessToken())->setFacebookId($response->getUsername());
     }
     if ($type === 'google') {
         $user->setGoogleToken($response->getAccessToken())->setGoogleId($response->getUsername());
     }
     $em->flush();
     return $user;
 }
开发者ID:Wolframcheg,项目名称:symfotest,代码行数:29,代码来源:LoginUserProvider.php

示例6: loadUserByOAuthUserResponse

 /**
  * {@inheritdoc}
  */
 public function loadUserByOAuthUserResponse(UserResponseInterface $response)
 {
     $user = new WebHomeUser($response->getNickname(), null, $response->getFirstName(), $response->getLastName(), $response->getLocale(), $response->getAccessToken(), $response->getRefreshToken());
     $user->initRolesAndApplications($response->getRoles());
     return $user;
 }
开发者ID:nicolasdewez,项目名称:webhome-common,代码行数:9,代码来源:WebHomeUserProvider.php


注:本文中的HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface::getFirstName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。