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


PHP UserResponseInterface::getNickname方法代码示例

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


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

示例1: 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

示例2: loadUserByOAuthUserResponse

 /**
  * {@inheritdoc}
  */
 public function loadUserByOAuthUserResponse(UserResponseInterface $response)
 {
     $findBy = array('name' => $response->getNickname(), 'githubId' => $response->getNickname());
     $user = $this->ownerManager->findDeveloperBy($findBy);
     if (!$user) {
         $user = $this->ownerManager->createOwner($findBy['name']);
         if (!$user) {
             throw new UsernameNotFoundException(sprintf('User with username "%s" could not found or created. If your account doesn\'t exists as github account, we can\'t connect you for now.', $findBy['name']));
         }
     }
     return $user;
 }
开发者ID:KnpLabs,项目名称:KnpBundles,代码行数:15,代码来源:UserProvider.php

示例3: loadUserByOAuthUserResponse

 public function loadUserByOAuthUserResponse(UserResponseInterface $response)
 {
     $google_id = $response->getUsername();
     $email = $response->getEmail();
     $nickname = $response->getNickname();
     $realname = $response->getRealName();
     $avatar = $response->getProfilePicture();
     $this->session->set('email', $email);
     $this->session->set('nickname', $nickname);
     $this->session->set('realname', $realname);
     $this->session->set('avatar', $avatar);
     $qb = $this->doctrine->getManager()->createQueryBuilder();
     $qb->select('u')->from('BookBundle:User', 'u')->where('u.googleId = :gid')->setParameter('gid', $google_id)->setMaxResults(1);
     $result = $qb->getQuery()->getResult();
     if (!count($result)) {
         $user = new User();
         $user->setUsername($google_id);
         $user->setRealname($realname);
         $user->setNickname($nickname);
         $user->setEmail($email);
         $user->setGoogleId($google_id);
         $user->setLocked(false);
         $factory = $this->container->get('security.encoder_factory');
         $encoder = $factory->getEncoder($user);
         $password = $encoder->encodePassword(md5(uniqid(), $user->getSalt()));
         $user->setPassword($password);
         $em = $this->doctrine->getManager();
         $em->persist($user);
         $em->flush();
     } else {
         $user = $result[0];
     }
     $this->session->set('id', $user->getId());
     return $this->loadUserByUsername($response->getUsername());
 }
开发者ID:bajke992,项目名称:book-app,代码行数:35,代码来源:OAuthProvider.php

示例4: loadUserByOAuthUserResponse

 /**
  * {@inheritdoc}
  */
 public function loadUserByOAuthUserResponse(UserResponseInterface $response)
 {
     $username = $response->getNickname();
     $twitterId = $response->getUsername();
     $accessToken = $response->getAccessToken();
     $secretToken = $response->getTokenSecret();
     $user = $this->userManager->findUserByUsername($username);
     //when the user is registrating
     if (is_null($user)) {
         // create new user here
         $user = $this->userManager->createUser();
         $user->setUsername($username);
         $user->setAccessToken($accessToken);
         $user->setTwitterId($twitterId);
         $user->setSecretToken($secretToken);
         //I have set all requested data with the user's username
         //modify here with relevant data
         $user->setEmail($username);
         $user->setPlainPassword($username);
         $user->setEnabled(true);
         $this->userManager->updateUser($user);
         return $user;
     }
     //if user exists - go with the HWIOAuth way
     $user->setAccessToken($accessToken);
     $user->setSecretToken($secretToken);
     return $user;
 }
开发者ID:josenava,项目名称:showHashtag,代码行数:31,代码来源:FOSUBUserProvider.php

示例5: loadUserByOAuthUserResponse

 /**
  * @param UserResponseInterface $response
  * @return User
  */
 public function loadUserByOAuthUserResponse(UserResponseInterface $response)
 {
     $username = $response->getUsername();
     /** @var User $user */
     $user = $this->userManager->findUserBy(['slackUserName' => $response->getUsername()]);
     if ($user === null) {
         $user = $this->userManager->createUser();
         $user->setSlackUserName($username);
         $user->setSlackAccessToken($response->getAccessToken());
         $user->setUsername($response->getNickname());
         $user->setEmail($response->getEmail());
         $user->setRealName($response->getRealName());
         $user->setPassword($username);
         $user->setEnabled(true);
         $this->userManager->updateUser($user);
         $token = new Token($user);
         $this->tokenRepository->persist($token);
         $user->addToken($token);
         $this->userManager->updateUser($user);
         return $user;
     }
     $user = parent::loadUserByOAuthUserResponse($response);
     $user->setSlackAccessToken($response->getAccessToken());
     $user->setRealName($response->getRealName());
     $token = new Token($user);
     $this->tokenRepository->persist($token);
     $user->addToken($token);
     $this->userManager->updateUser($user);
     return $user;
 }
开发者ID:jordi12100,项目名称:ExpertTools,代码行数:34,代码来源:UserProvider.php

示例6: loadUserByOAuthUserResponse

 /**
  * {@inheritdoc}
  */
 public function loadUserByOAuthUserResponse(UserResponseInterface $response)
 {
     $username = $response->getUsername();
     $email = $response->getEmail();
     $nickname = $response->getNickname();
     $user = $this->userManager->findUserBy(array($this->getProperty($response) => $username));
     //when the user is registrating
     if (null === $user) {
         $service = $response->getResourceOwner()->getName();
         $setter = 'set' . ucfirst($service);
         $setter_id = $setter . 'Id';
         $setter_token = $setter . 'AccessToken';
         // create new user here
         $user = $this->userManager->createUser();
         $user->{$setter_id}($username);
         $user->{$setter_token}($response->getAccessToken());
         //I have set all requested data with the user's username
         //modify here with relevant data
         $user->setUsername($nickname);
         $user->setEmail($email);
         $user->setPassword($username);
         $user->setEnabled(true);
         $this->userManager->updateUser($user);
         return $user;
     }
     //if user exists - go with the HWIOAuth way
     $user = parent::loadUserByOAuthUserResponse($response);
     $serviceName = $response->getResourceOwner()->getName();
     $setter = 'set' . ucfirst($serviceName) . 'AccessToken';
     //update access token
     $user->{$setter}($response->getAccessToken());
     return $user;
 }
开发者ID:kvartiri,项目名称:kvartiri,代码行数:36,代码来源:FOSUBUserProvider.php

示例7: 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

示例8: loadUserByOAuthUserResponse

 public function loadUserByOAuthUserResponse(UserResponseInterface $response)
 {
     //data from facebook response
     //		dump($response->getAccessToken(), $response->getRefreshToken());
     //		die();
     $id = $response->getUsername();
     $nickname = $response->getNickname();
     $email = $response->getEmail();
     //set data in session
     $this->session->set('id', $id);
     $this->session->set('email', $email);
     $this->session->set('access_token', $response->getAccessToken());
     $this->session->set('refresh_token', $response->getRefreshToken());
     /*
     //get user by fid
     $qb = $this->doctrine->getManager()->createQueryBuilder();
     $qb ->select('u.id')
     	->from('AcmeDemoBundle:User', 'u')
     	->where('u.fid = :fid')
     	->setParameter('fid', $facebook_id)
     	->setMaxResults(1);
     $result = $qb->getQuery()->getResult();
     
     //add to database if doesn't exists
     if ( !count($result) ) {
     	$User = new User();
     	$User->setCreatedAt(new \DateTime());
     	$User->setNickname($nickname);
     	$User->setRealname($realname);
     	$User->setEmail($email);
     	$User->setAvatar($avatar);
     	$User->setFID($facebook_id);
     
     	$em = $this->doctrine->getManager();
     	$em->persist($User);
     	$id = $em->flush();
     } else {
     	$id = $result[0]['id'];
     }
     */
     //@TODO: hmm : is admin
     if ($this->isUserAdmin($nickname)) {
         $this->session->set('is_admin', true);
     }
     //parent:: returned value
     return $this->loadUserByUsername($response->getNickname());
 }
开发者ID:Avazanga1,项目名称:OAuth-Client-Demo,代码行数:47,代码来源:Provider.php

示例9: loadUserByOAuthUserResponse

 /**
  * {@inheritdoc}
  */
 public function loadUserByOAuthUserResponse(UserResponseInterface $response)
 {
     $resourceOwner = $response->getResourceOwner();
     if (!$resourceOwner instanceof FacebookResourceOwner) {
         throw new UnsupportedUserException('Only Facebook users are supported');
     }
     return $this->loadUserByData(['userId' => $response->getUsername(), 'service' => 'facebook', 'username' => $response->getNickname(), 'realname' => $response->getRealName(), 'email' => $response->getEmail(), 'picture' => $response->getProfilePicture()]);
 }
开发者ID:paza,项目名称:HotOrNot,代码行数:11,代码来源:OAuthUserProvider.php

示例10: loginUserFaceBook

 private function loginUserFaceBook(UserResponseInterface $response)
 {
     $username = $response->getNickname();
     $firstName = $response->getResponse()['first_name'];
     $lastName = $response->getResponse()['last_name'];
     $gender = $response->getResponse()['gender'];
     $email = $response->getEmail();
     return ['loginField' => 'fbLogin', 'username' => $username, 'firstName' => $firstName, 'lastName' => $lastName, 'gender' => $gender, 'email' => $email];
 }
开发者ID:rotanov,项目名称:fefu-social-network,代码行数:9,代码来源:OAuthUserProvider.php

示例11: loadUserByOAuthUserResponse

    public function loadUserByOAuthUserResponse(UserResponseInterface $response)
    {
        //Data from Google response
        $social_id = $response->getUsername(); /* An ID like: 112259658235204980084 */
        $email = $response->getEmail();
        $nickname = $response->getNickname();
        $realname = $response->getRealName();
        $avatar = $response->getProfilePicture();

        //set data in session
        $this->session->set('email', $email);
        $this->session->set('nickname', $nickname);
        $this->session->set('realname', $realname);
        $this->session->set('avatar', $avatar);

        //Check if this Google user already exists in our app DB
        $qb = $this->doctrine->getManager()->createQueryBuilder();
        $qb->select('u')
            ->from('BloggerBlogBundle:User', 'u')
            ->where('u.socialId = :sid')
            ->setParameter('sid', $social_id)
            ->setMaxResults(1);
        $result = $qb->getQuery()->getResult();

        //add to database if doesn't exists
        if (!count($result)) {
            $user = new User();
            $user->setUsername($social_id);
            $user->setRealname($realname);
            $user->setNickname($nickname);
            $user->setEmail($email);
            $user->setSocialId($social_id);
            //$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($user);
            $password = $encoder->encodePassword(md5(uniqid()), $user->getSalt());
            $user->setPassword($password);

            $em = $this->doctrine->getManager();
            $em->persist($user);
            $em->flush();
        } else {
            $user = $result[0]; /* return User */
        }

        //set id
        $this->session->set('id', $user->getId());

        return $this->loadUserByUsername($response->getUsername());
    }
开发者ID:artemzakholodilo,项目名称:blog,代码行数:52,代码来源:OAuthProvider.php

示例12: setUserInformation

 /**
  * Set user information from form
  *
  * @param UserInterface         $user
  * @param UserResponseInterface $userInformation
  *
  * @return UserInterface
  */
 protected function setUserInformation(UserInterface $user, UserResponseInterface $userInformation)
 {
     $user->setUsername($this->getUniqueUsername($userInformation->getNickname()));
     foreach ($userInformation->getPaths() as $field => $map) {
         $func = $this->camelize($field);
         $setter = 'set' . $func;
         $getter = 'get' . $func;
         if (method_exists($user, $setter)) {
             $user->{$setter}($userInformation->{$getter}());
         }
     }
     return $user;
 }
开发者ID:b4zs,项目名称:OAuthBundle,代码行数:21,代码来源:RegistrationFormHandler.php

示例13: createUserByOAuthUserResponse

 /**
  * Ad-hoc creation of user
  *
  * @param UserResponseInterface $response
  *
  * @return SyliusUserInterface
  */
 protected function createUserByOAuthUserResponse(UserResponseInterface $response)
 {
     $user = $this->userManager->createUser();
     // set default values taken from OAuth sign-in provider account
     if (null !== ($email = $response->getEmail())) {
         $user->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->setEnabled(true);
     return $this->updateUserByOAuthUserResponse($user, $response);
 }
开发者ID:gaetzone,项目名称:Sylius,代码行数:22,代码来源:UserProvider.php

示例14: process

 /**
  * {@inheritDoc}
  */
 public function process(Request $request, Form $form, UserResponseInterface $userInformation)
 {
     $formHandler = $this->reconstructFormHandler($request, $form);
     // make FOSUB process the form already
     $processed = $formHandler->process();
     // if the form is not posted we'll try to set some properties
     if ('POST' !== $request->getMethod()) {
         $user = $form->getData();
         $user->setUsername($this->getUniqueUsername($userInformation->getNickname()));
         if ($userInformation instanceof AdvancedUserResponseInterface && method_exists($user, 'setEmail')) {
             $user->setEmail($userInformation->getEmail());
         }
         $form->setData($user);
     }
     return $processed;
 }
开发者ID:rafalwrzeszcz,项目名称:HWIOAuthBundle,代码行数:19,代码来源:FOSUBRegistrationFormHandler.php

示例15: createUserFromResponse

 /**
  * Create user from response
  *
  * @param UserResponseInterface $response
  *
  * @return User
  */
 private function createUserFromResponse(UserResponseInterface $response)
 {
     $email = $response->getEmail() ?: $response->getUsername() . '@example.com';
     /** @var User $user */
     $user = $this->userManager->createUser();
     $user->setEmail($email);
     $user->setUsername($response->getNickname());
     $user->setEnabled(true);
     $user->setPlainPassword(uniqid());
     $user->setGithubId($response->getUsername());
     // Move to separate listener
     if (in_array($response->getUsername(), $this->adminGitHubIds)) {
         $user->addRole('ROLE_ADMIN');
     }
     $this->userManager->updateUser($user);
     return $user;
 }
开发者ID:stfalcon-studio,项目名称:codedill,代码行数:24,代码来源:AuthProvider.php


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