/** * Perform login action * * @return void */ protected function doActionLogin() { $authProviders = \XLite\Module\CDev\SocialLogin\Core\AuthManager::getAuthProviders(); $requestProcessed = false; foreach ($authProviders as $authProvider) { if ($authProvider->detectAuth()) { $profileInfo = $authProvider->processAuth(); if ($profileInfo && !empty($profileInfo['id']) && !empty($profileInfo['email'])) { $profile = $this->getSocialLoginProfile($profileInfo['email'], $authProvider->getName(), $profileInfo['id']); if ($profile) { if ($profile->isEnabled()) { \XLite\Core\Auth::getInstance()->loginProfile($profile); $this->setAuthReturnURL($authProvider::STATE_PARAM_NAME); } else { \XLite\Core\TopMessage::addError('Profile is disabled'); $this->setAuthReturnURL($authProvider::STATE_PARAM_NAME, true); } } else { $provider = \XLite\Core\Database::getRepo('XLite\\Model\\Profile')->findOneBy(array('login' => $profileInfo['email'], 'order' => null))->getSocialLoginProvider(); if ($provider) { $signInVia = 'Please sign in with ' . $provider . '.'; } else { $signInVia = 'Profile with the same e-mail address already registered. ' . 'Please sign in the classic way.'; } \XLite\Core\TopMessage::addError($signInVia); $this->setAuthReturnURL($authProvider::STATE_PARAM_NAME, true); } $requestProcessed = true; } } } if (!$requestProcessed) { \XLite\Core\TopMessage::addError('We were unable to process this request'); $this->setAuthReturnURL('', true); } }
/** * Get all configured authentication providers * * @return array Auth providers list */ public function getAuthProviders() { return \XLite\Module\CDev\SocialLogin\Core\AuthManager::getAuthProviders(); }
/** * Check if widget is visible * * @return boolean */ protected function isVisible() { $authProviders = \XLite\Module\CDev\SocialLogin\Core\AuthManager::getAuthProviders(); return parent::isVisible() && !\XLite\Core\Auth::getInstance()->isLogged() && !empty($authProviders); }
/** * Get all available authentication providers class names * * @return array List of auth provider class names (\XLite\Module\CDev\SocialLogin\Core\AAuthProvider descendants) */ protected static function getAuthProvidersClassNames() { $list = parent::getAuthProvidersClassNames(); $list[] = 'XLite\\Module\\CDev\\Paypal\\Core\\PaypalAuthProvider'; return $list; }