Esempio n. 1
0
 /**
  * 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);
     }
 }
Esempio n. 2
0
 /**
  * Get all configured authentication providers
  *
  * @return array Auth providers list
  */
 public function getAuthProviders()
 {
     return \XLite\Module\CDev\SocialLogin\Core\AuthManager::getAuthProviders();
 }
Esempio n. 3
0
 /**
  * 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);
 }