src/PHPDish/Bundle/UserBundle/Security/Core/User/FOSUBUserProvider.php
public function loadUserByOAuthUserResponse(UserResponseInterface $response)
    {
        //优先查找对应用户，否则使用当前登录用户，否则按照邮箱查找，否则创建新用户
        $username = $response->getUsername();
        $user = $this->userManager->findUserBy([$this->getProperty($response) => $username]) ?: $this->getAuthenticatedUser();
        if (!$user) {
            $user = $this->userManager->findUserByEmail($response->getEmail()) ?: $this->createNewUser($response);
        }

        $serviceName = $response->getResourceOwner()->getName();
        $accessTokenSetter = 'set'.ucfirst($serviceName).'AccessToken';
        $user->$accessTokenSetter($response->getAccessToken());
        $idSetter = 'set'.ucfirst($serviceName).'Id';
        $user->$idSetter($response->getUsername());

        return $user;
    }
public function loadUserByOAuthUserResponse(UserResponseInterface $response)
    {
        //优先查找对应用户，否则使用当前登录用户，否则按照邮箱查找，否则创建新用户
        $username = $response->getUsername();
        $user = $this->userManager->findUserBy([$this->getProperty($response) => $username]) ?: $this->getAuthenticatedUser();
        if (!$user) {
            $user = $this->userManager->findUserByEmail($response->getEmail()) ?: $this->createNewUser($response);
        }

        $serviceName = $response->getResourceOwner()->getName();
        $accessTokenSetter = 'set'.ucfirst($serviceName).'AccessToken';
        $user->$accessTokenSetter($response->getAccessToken());
        $idSetter = 'set'.ucfirst($serviceName).'Id';
        $user->$idSetter($response->getUsername());

        return $user;
    }
{@inheritdoc}