getConnectedProviders() публичный статический Метод

Return array listing all authenticated providers
public static getConnectedProviders ( ) : array
Результат array
 /**
  * Check if a provider already connected return user record if available
  *
  * @param Request $request Request instance.
  * @return array|bool User array on success, false on failure.
  */
 public function getUser(Request $request)
 {
     $this->_init($request);
     $idps = $this->hybridAuth->getConnectedProviders();
     foreach ($idps as $provider) {
         $adapter = $this->hybridAuth->getAdapter($provider);
         return $this->_getUser($provider, $adapter);
     }
     return false;
 }
Пример #2
0
 /**
  * Gets user profile from service
  *
  * @param string $provider Service provider, like Google, Twitter etc.
  *
  * @return array|boolean
  */
 function getServiceProfile($provider = '')
 {
     $providers = $this->Hybrid_Auth->getConnectedProviders();
     $providerId = ucfirst($provider);
     if (is_array($providers) && in_array($provider, $providers)) {
         /* @var Hybrid_Providers_Google $provider */
         $provider = $this->Hybrid_Auth->getAdapter($providerId);
         $profile = $provider->getUserProfile();
         $array = json_encode($profile);
         return json_decode($array, true);
     } else {
         return false;
     }
 }
Пример #3
0
 /**
  * A generic function to logout all connected provider at once
  */
 public static function logoutAllProviders()
 {
     $idps = Hybrid_Auth::getConnectedProviders();
     foreach ($idps as $idp) {
         $adapter = Hybrid_Auth::getAdapter($idp);
         $adapter->logout();
     }
 }
Пример #4
0
    public function showProviders($text = '')
    {
        $config = (include SYSTEM_PATH . '/hybridauth/config.php');
        if ($config['active'] == 0) {
            return array('providers' => 0);
        }
        $config_url = SYSTEM_PATH . '/hybridauth/config.php';
        require_once SYSTEM_PATH . '/hybridauth/Hybrid/Auth.php';
        $connectedto = array();
        $curConnected = array();
        if ($this->loggedin) {
            $stmt = $this->sql->prepare('SELECT provider_name FROM social_connect WHERE member_id = ?');
            $stmt->execute(array($this->uid));
            foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
                $connectedto[] = $row['provider_name'];
            }
            $stmt->closeCursor();
            // initialize Hybrid_Auth with a given file
            $hybridauth = new Hybrid_Auth($config_url);
            $curConnected = $hybridauth->getConnectedProviders();
        }
        // Make the list
        if ($config['active'] == 0) {
            return '';
        }
        $output = '';
        $c = 0;
        foreach ($config['providers'] as $name => $conf) {
            if ($name != 'OpenID' && $conf['enabled']) {
                if ($this->loggedin) {
                    $output .= '<div class="span2">
									<img src="images/social/' . strtolower($name) . '.png" alt="">' . (!in_array($name, $connectedto) ? '<a href="?link=' . $name . '" class="owloo_btn owloo_btn_blue">Conectar</a>' : '<a href="?unlink=' . $name . '" class="btn btn-small btn-danger">Desconectar</a>') . '
								</div>';
                } else {
                    $output .= '<a href="?provider=' . $name . '" class="owloo_login_icons zocial ' . strtolower($name) . '">' . $name . '</a>';
                    //$output .= '<a href="?provider='.$name.'" class="owloo_login_icons zocial '.strtolower($name).'"><img src="'.URL_IMAGES.'social-icons/'.strtolower($name).'-icon.png" alt="'.strtolower($name).'" /></a>';
                }
                $c++;
            }
        }
        if ($this->loggedin) {
            return $output;
        } else {
            return array('providers' => $c, 'links' => $output);
        }
    }
Пример #5
0
			&nbsp;&nbsp;<a href="?provider=Google">Sign-in with Google</a><br /> 
			&nbsp;&nbsp;<a href="?provider=Yahoo">Sign-in with Yahoo</a><br /> 
			&nbsp;&nbsp;<a href="?provider=Facebook">Sign-in with Facebook</a><br />
			&nbsp;&nbsp;<a href="?provider=Twitter">Sign-in with Twitter</a><br />
			&nbsp;&nbsp;<a href="?provider=MySpace">Sign-in with MySpace</a><br />  
			&nbsp;&nbsp;<a href="?provider=Live">Sign-in with Windows Live</a><br />  
			&nbsp;&nbsp;<a href="?provider=LinkedIn">Sign-in with LinkedIn</a><br /> 
			&nbsp;&nbsp;<a href="?provider=Foursquare">Sign-in with Foursquare</a><br /> 
			&nbsp;&nbsp;<a href="?provider=AOL">Sign-in with AOL</a><br />  
      </fieldset> 
	</td> 
<?php 
// try to get already authenticated provider list
try {
    $hybridauth = new Hybrid_Auth($config);
    $connected_adapters_list = $hybridauth->getConnectedProviders();
    if (count($connected_adapters_list)) {
        ?>
 
    <td align="left" valign="top">  
		<fieldset>
			<legend>Providers you are logged with</legend>
			<?php 
        foreach ($connected_adapters_list as $adapter_id) {
            echo '&nbsp;&nbsp;<a href="profile.php?provider=' . $adapter_id . '">Switch to <b>' . $adapter_id . '</b>  account</a><br />';
        }
        ?>
 
		</fieldset> 
	</td>		
<?php 
Пример #6
0
 public function tryProviderSession($deniedAs)
 {
     // don't allow if main admin browse front-end or there is already user session
     if (!$deniedAs && $this->getSessionDataAs() || null !== $this->_session_data || !e107::getPref('social_login_active', false)) {
         return $this;
     }
     try {
         // detect all currently connected providers
         $hybrid = e107::getHybridAuth();
         // init the auth class
         $connected = Hybrid_Auth::getConnectedProviders();
     } catch (Exception $e) {
         e107::getMessage()->addError('[' . $e->getCode() . ']' . $e->getMessage(), 'default', true);
         $session = e107::getSession();
         $session->set('HAuthError', true);
         $connected = false;
     }
     // no active session found
     if (!$connected) {
         return $this;
     }
     // query DB
     $sql = e107::getDb();
     $where = array();
     foreach ($connected as $providerId) {
         $adapter = Hybrid_Auth::getAdapter($providerId);
         if (!$adapter->getUserProfile()->identifier) {
             continue;
         }
         $id = $providerId . '_' . $adapter->getUserProfile()->identifier;
         $where[] = "user_xup='" . $sql->escape($id) . "'";
     }
     $where = implode(' OR ', $where);
     if ($sql->db_Select('user', 'user_id, user_password, user_xup', $where)) {
         $user = $sql->db_Fetch();
         e107::getUserSession()->makeUserCookie($user);
         $this->setSessionData();
     }
     return $this;
 }
Пример #7
0
function wsl_get_list_connected_providers()
{
    // load hybridauth
    require_once WORDPRESS_SOCIAL_LOGIN_ABS_PATH . "/hybridauth/Hybrid/Auth.php";
    global $WORDPRESS_SOCIAL_LOGIN_PROVIDERS_CONFIG;
    $config = array();
    foreach ($WORDPRESS_SOCIAL_LOGIN_PROVIDERS_CONFIG as $item) {
        $provider_id = @$item["provider_id"];
        $config["providers"][$provider_id]["enabled"] = true;
    }
    $hybridauth = new Hybrid_Auth($config);
    return Hybrid_Auth::getConnectedProviders();
}
Пример #8
0
function isUserLogged() {
	global $_S;
	if( isset($GLOBALS['userIsLoggedIn']) && $GLOBALS['userIsLoggedIn'] ) {
		return true;
	} elseif( false && Db_Users::isLogged() ) {
		$GLOBALS['userIsLoggedIn'] = true;
		return true;
	} elseif( count(Hybrid_Auth::getConnectedProviders()) && $_S->Exist('authentication_info') ) {
		$providers = Hybrid_Auth::getConnectedProviders();
		$auth = $_S->Get('authentication_info');
		$user = Db_Users::getObjectDetails($auth['user_id']);
		Db_Users::loginWithUser( $user );


		// TODO Do some checking
		$GLOBALS['userIsLoggedIn'] = true;
	}

	return false;
}
Пример #9
0
 function __construct($db_conn, $table)
 {
     parent::__construct($db_conn, $table);
     //
     // Check if user is valid in DB.
     //
     $hybrid_types = array("facebook", "google", "yahoo", "live");
     $provider = $this->getUserName();
     // create an instance for Hybridauth with the configuration file path as parameter
     $hybridauth_config = "hybridauth" . DIRECTORY_SEPARATOR . "config.php";
     require_once "hybridauth" . DIRECTORY_SEPARATOR . "Hybrid" . DIRECTORY_SEPARATOR . "Auth.php";
     $hybridauth = new Hybrid_Auth($hybridauth_config);
     $loaded_providers = Hybrid_Auth::getConnectedProviders();
     if ($provider == "" && count($loaded_providers) > 0) {
         $provider = strtolower($loaded_providers[0]);
     }
     if ($provider != "" && in_array($provider, $hybrid_types)) {
         try {
             // try to authenticate the selected $provider
             $adapter = $hybridauth->authenticate($provider);
             // grab the user profile
             $user_profile = $adapter->getUserProfile();
             // a) Does user with "xxx" = identifier exist?
             //   -> Yes, then login as user
             // b) Does email of user exist?
             //   -> No, then create new user
             // c) Does email of user exist?
             //   -> Yes, ask for regular login. Preset email = login
             $provider_uid = $user_profile->identifier;
             $email = $user_profile->email;
             //
             // Check if user is valid in DB.
             //
             $sql = "select user_id, domain_id, username, md5_pass from " . $table . " where sso_" . strtolower($provider) . "_uid = '" . $provider_uid . "';";
             $result = mysql_query($sql);
             $rec = mysql_fetch_array($result);
             $cnt = mysql_numrows($result);
             if ($cnt == 1) {
                 $this->user_id = $rec['user_id'];
                 $this->username = $rec['username'];
                 $this->md5_pass = $rec['md5_pass'];
                 $this->user_cfg = array('domain' => $rec['domain_id']);
             }
         } catch (Exception $e) {
             // Display the recived error
             switch ($e->getCode()) {
                 case 0:
                     $error = "Unspecified error.";
                     break;
                 case 1:
                     $error = "Hybriauth configuration error.";
                     break;
                 case 2:
                     $error = "Provider not properly configured.";
                     break;
                 case 3:
                     $error = "Unknown or disabled provider.";
                     break;
                 case 4:
                     $error = "Missing provider application credentials.";
                     break;
                 case 5:
                     $error = "Authentification failed. The user has canceled the authentication or the provider refused the connection.";
                     break;
                 case 6:
                     $error = "User profile request failed. Most likely the user is not connected to the provider and he should to authenticate again.";
                     $adapter->logout();
                     break;
                 case 7:
                     $error = "User not connected to the provider.";
                     $adapter->logout();
                     break;
             }
             echo $error;
         }
     }
     $this->finishConstruct();
 }