src/Sylius/Bundle/CoreBundle/OAuth/UserProvider.php
private function updateUserByOAuthUserResponse(UserInterface $user, UserResponseInterface $response): SyliusUserInterface
    {
        /** @var SyliusUserInterface $user */
        Assert::isInstanceOf($user, SyliusUserInterface::class);

        /** @var UserOAuthInterface $oauth */
        $oauth = $this->oauthFactory->createNew();
        $oauth->setIdentifier($response->getUsername());
        $oauth->setProvider($response->getResourceOwner()->getName());
        $oauth->setAccessToken($response->getAccessToken());
        $oauth->setRefreshToken($response->getRefreshToken());

        $user->addOAuthAccount($oauth);

        $this->userManager->persist($user);
        $this->userManager->flush();

        return $user;
    }
private function updateUserByOAuthUserResponse(UserInterface $user, UserResponseInterface $response): SyliusUserInterface
    {
        /** @var SyliusUserInterface $user */
        Assert::isInstanceOf($user, SyliusUserInterface::class);

        /** @var UserOAuthInterface $oauth */
        $oauth = $this->oauthFactory->createNew();
        $oauth->setIdentifier($response->getUsername());
        $oauth->setProvider($response->getResourceOwner()->getName());
        $oauth->setAccessToken($response->getAccessToken());
        $oauth->setRefreshToken($response->getRefreshToken());

        $user->addOAuthAccount($oauth);

        $this->userManager->persist($user);
        $this->userManager->flush();

        return $user;
    }
private function updateUserByOAuthUserResponse ( UserInterface $ user , UserResponseInterface $ response ) : SyliusUserInterface { /** @var SyliusUserInterface $user */ Assert :: isInstanceOf ( $ user , SyliusUserInterface :: class ) ; /** @var UserOAuthInterface $oauth */ $ oauth = $ this -> oauthFactory -> createNew ( ) ; $ oauth -> setIdentifier ( $ response -> getUsername ( ) ) ; $ oauth -> setProvider ( $ response -> getResourceOwner ( ) -> getName ( ) ) ; $ oauth -> setAccessToken ( $ response -> getAccessToken ( ) ) ; $ oauth -> setRefreshToken ( $ response -> getRefreshToken ( ) ) ; $ user -> addOAuthAccount ( $ oauth ) ; $ this -> userManager -> persist ( $ user ) ; $ this -> userManager -> flush ( ) ; return $ user ; }
Attach OAuth sign-in provider account to existing user.
Attach OAuth sign - in provider account to existing user .