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;
    }