本文整理汇总了PHP中Symfony\Component\Security\Core\User\UserInterface::addOAuthAccount方法的典型用法代码示例。如果您正苦于以下问题:PHP UserInterface::addOAuthAccount方法的具体用法?PHP UserInterface::addOAuthAccount怎么用?PHP UserInterface::addOAuthAccount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Security\Core\User\UserInterface
的用法示例。
在下文中一共展示了UserInterface::addOAuthAccount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: connect
/**
* {@inheritDoc}
*/
public function connect(UserInterface $user, UserResponseInterface $response)
{
$providerName = $response->getResourceOwner()->getName();
$uniqueId = $response->getUsername();
$user->addOAuthAccount($providerName, $uniqueId);
$this->userManager->updateUser($user);
}
示例2: updateUserByOAuthUserResponse
/**
* {@inheritdoc}
*/
protected function updateUserByOAuthUserResponse(UserInterface $user, UserResponseInterface $response)
{
/** @var UserOAuthInterface $oauth */
$oauth = $this->oauthFactory->createNew();
$oauth->setIdentifier($response->getUsername());
$oauth->setProvider($response->getResourceOwner()->getName());
$oauth->setAccessToken($response->getAccessToken());
$oauth->setProfilePicture($response->getProfilePicture());
/* @var DoSUserInterface $user */
$user->addOAuthAccount($oauth);
$this->userManager->persist($user);
$this->userManager->flush();
return $user;
}
示例3: updateUserByOAuthUserResponse
/**
* Attach OAuth sign-in provider account to existing user.
*
* @param UserInterface $user
* @param UserResponseInterface $response
*
* @return UserInterface
*/
private function updateUserByOAuthUserResponse(UserInterface $user, UserResponseInterface $response)
{
$oauth = $this->oauthFactory->createNew();
$oauth->setIdentifier($response->getUsername());
$oauth->setProvider($response->getResourceOwner()->getName());
$oauth->setAccessToken($response->getAccessToken());
$oauth->setRefreshToken($response->getRefreshToken());
/* @var $user SyliusUserInterface */
$user->addOAuthAccount($oauth);
$this->userManager->persist($user);
$this->userManager->flush();
return $user;
}