public function loginAndRegisterVia($provider)
    {
        $this->authenticationService = $this->authenticationServiceFactory->getInstance($provider);

        $isUserLoggedIn = $this->accountService->checkUser();

        // active sw login session
        if ($isUserLoggedIn) {
            return $isUserLoggedIn;
        }

        if ($this->authenticationService !== null) {
            // sso login
            $isAuthenticated = $this->authenticationService->login();
            $customer = null;
            if ($isAuthenticated) {
                // get user data from sso provider
                $user = $this->authenticationService->getUser();
                if ($user !== null && $user->getEmail() !== '') {
                    // get sw customer
                    $customer = $this->customerService->getCustomerByIdentity($provider, $user->getId());
                    if ($customer !== null) {
                        // new login
                        $isUserLoggedIn = $this->tryLoginCustomer($customer);
                    } else {
                        $customer = $this->customerService->getCustomerByEmail($user->getEmail());
                        if ($customer !== null) {
                            // connect
                            $customer = $this->registerService->connectUserWithExistingCustomer($user, $customer);
                        } else {
                            // register
                            $customer = $this->registerService->registerCustomerByUser($user);
                        }
                        $isUserLoggedIn = $this->tryLoginCustomer($customer);
                    }
                }
            } else {
                $isUserLoggedIn = false;
            }

            $this->container->get('events')->notify(
                'Port1HybridAuth_Service_SingleSignOn_CustomerLoggedIn',
                [
                    'customer' => $customer,
                    'isUserLoggedIn' => $isUserLoggedIn
                ]
            );
        }
        return $isUserLoggedIn;
    }
public function loginAndRegisterVia($provider)
    {
        $this->authenticationService = $this->authenticationServiceFactory->getInstance($provider);

        $isUserLoggedIn = $this->accountService->checkUser();

        // active sw login session
        if ($isUserLoggedIn) {
            return $isUserLoggedIn;
        }

        if ($this->authenticationService !== null) {
            // sso login
            $isAuthenticated = $this->authenticationService->login();
            $customer = null;
            if ($isAuthenticated) {
                // get user data from sso provider
                $user = $this->authenticationService->getUser();
                if ($user !== null && $user->getEmail() !== '') {
                    // get sw customer
                    $customer = $this->customerService->getCustomerByIdentity($provider, $user->getId());
                    if ($customer !== null) {
                        // new login
                        $isUserLoggedIn = $this->tryLoginCustomer($customer);
                    } else {
                        $customer = $this->customerService->getCustomerByEmail($user->getEmail());
                        if ($customer !== null) {
                            // connect
                            $customer = $this->registerService->connectUserWithExistingCustomer($user, $customer);
                        } else {
                            // register
                            $customer = $this->registerService->registerCustomerByUser($user);
                        }
                        $isUserLoggedIn = $this->tryLoginCustomer($customer);
                    }
                }
            } else {
                $isUserLoggedIn = false;
            }

            $this->container->get('events')->notify(
                'Port1HybridAuth_Service_SingleSignOn_CustomerLoggedIn',
                [
                    'customer' => $customer,
                    'isUserLoggedIn' => $isUserLoggedIn
                ]
            );
        }
        return $isUserLoggedIn;
    }
public function loginAndRegisterVia ( $ provider ) { $ this -> authenticationService = $ this -> authenticationServiceFactory -> getInstance ( $ provider ) ; $ isUserLoggedIn = $ this -> accountService -> checkUser ( ) ; // active sw login session if ( $ isUserLoggedIn ) { return $ isUserLoggedIn ; } if ( $ this -> authenticationService !== null ) { // sso login $ isAuthenticated = $ this -> authenticationService -> login ( ) ; $ customer = null ; if ( $ isAuthenticated ) { // get user data from sso provider $ user = $ this -> authenticationService -> getUser ( ) ; if ( $ user !== null && $ user -> getEmail ( ) !== '' ) { // get sw customer $ customer = $ this -> customerService -> getCustomerByIdentity ( $ provider , $ user -> getId ( ) ) ; if ( $ customer !== null ) { // new login $ isUserLoggedIn = $ this -> tryLoginCustomer ( $ customer ) ; } else { $ customer = $ this -> customerService -> getCustomerByEmail ( $ user -> getEmail ( ) ) ; if ( $ customer !== null ) { // connect $ customer = $ this -> registerService -> connectUserWithExistingCustomer ( $ user , $ customer ) ; } else { // register $ customer = $ this -> registerService -> registerCustomerByUser ( $ user ) ; } $ isUserLoggedIn = $ this -> tryLoginCustomer ( $ customer ) ; } } } else { $ isUserLoggedIn = false ; } $ this -> container -> get ( 'events' ) -> notify ( 'Port1HybridAuth_Service_SingleSignOn_CustomerLoggedIn' , [ 'customer' => $ customer , 'isUserLoggedIn' => $ isUserLoggedIn ] ) ; } return $ isUserLoggedIn ; }
the overall method for the SSO workflow login + register

@param $provider string the authsource string (e.g.: linkedin, ...)
@return bool
the overall method for the SSO workflow login + register