src/Synapse/SocialLogin/SocialLoginService.php
public function handleLoginRequest(LoginRequest $request)
    {
        $socialLogin = $this->socialLoginMapper->findByProviderUserId(
            $request->getProvider(),
            $request->getProviderUserId()
        );

        if ($socialLogin) {
            $user = $this->userService->findById(
                $socialLogin->getUserId()
            );
            $this->updateSocialLoginToken($socialLogin, $request);
            return $this->handleLogin($user, $request);
        }

        $userFound = false;
        foreach ($request->getEmails() as $email) {
            $user = $this->userService->findByEmail($email);

            if ($user) {
                $userFound = true;
                if ($this->userHasSocialLoginWithProvider($request->getProvider(), $user)) {
                    return $this->handleLogin($user, $request);
                }
            }
        }

        if ($userFound) {
            throw new NoLinkedAccountException;
        }

        $result = $this->registerFromSocialLogin($request);

        return $this->handleLogin($result['user']);
    }
public function handleLoginRequest(LoginRequest $request)
    {
        $socialLogin = $this->socialLoginMapper->findByProviderUserId(
            $request->getProvider(),
            $request->getProviderUserId()
        );

        if ($socialLogin) {
            $user = $this->userService->findById(
                $socialLogin->getUserId()
            );
            $this->updateSocialLoginToken($socialLogin, $request);
            return $this->handleLogin($user, $request);
        }

        $userFound = false;
        foreach ($request->getEmails() as $email) {
            $user = $this->userService->findByEmail($email);

            if ($user) {
                $userFound = true;
                if ($this->userHasSocialLoginWithProvider($request->getProvider(), $user)) {
                    return $this->handleLogin($user, $request);
                }
            }
        }

        if ($userFound) {
            throw new NoLinkedAccountException;
        }

        $result = $this->registerFromSocialLogin($request);

        return $this->handleLogin($result['user']);
    }
public function handleLoginRequest ( LoginRequest $ request ) { $ socialLogin = $ this -> socialLoginMapper -> findByProviderUserId ( $ request -> getProvider ( ) , $ request -> getProviderUserId ( ) ) ; if ( $ socialLogin ) { $ user = $ this -> userService -> findById ( $ socialLogin -> getUserId ( ) ) ; $ this -> updateSocialLoginToken ( $ socialLogin , $ request ) ; return $ this -> handleLogin ( $ user , $ request ) ; } $ userFound = false ; foreach ( $ request -> getEmails ( ) as $ email ) { $ user = $ this -> userService -> findByEmail ( $ email ) ; if ( $ user ) { $ userFound = true ; if ( $ this -> userHasSocialLoginWithProvider ( $ request -> getProvider ( ) , $ user ) ) { return $ this -> handleLogin ( $ user , $ request ) ; } } } if ( $ userFound ) { throw new NoLinkedAccountException ; } $ result = $ this -> registerFromSocialLogin ( $ request ) ; return $ this -> handleLogin ( $ result [ 'user' ] ) ; }
Handle a request to log in via a social login provider

@param  LoginRequest $request
@return array        Access token
Handle a request to log in via a social login provider