当前位置: 首页>>代码示例>>PHP>>正文


PHP Hybrid_Auth::getConnectedProviders方法代码示例

本文整理汇总了PHP中Hybrid_Auth::getConnectedProviders方法的典型用法代码示例。如果您正苦于以下问题:PHP Hybrid_Auth::getConnectedProviders方法的具体用法?PHP Hybrid_Auth::getConnectedProviders怎么用?PHP Hybrid_Auth::getConnectedProviders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Hybrid_Auth的用法示例。


在下文中一共展示了Hybrid_Auth::getConnectedProviders方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getUser

 /**
  * 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;
 }
开发者ID:jamiefifty,项目名称:CakePHP-HybridAuth,代码行数:16,代码来源:HybridAuthAuthenticate.php

示例2: getServiceProfile

 /**
  * 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;
     }
 }
开发者ID:govza,项目名称:modx-hybridauth,代码行数:21,代码来源:hybridauth.class.php

示例3: logoutAllProviders

 /**
  * 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();
     }
 }
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:11,代码来源:Auth.php

示例4: showProviders

    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);
        }
    }
开发者ID:newbacknew,项目名称:owloo.com,代码行数:46,代码来源:class_usersystem.php

示例5: foreach

			&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 
开发者ID:niQo,项目名称:hybridauth,代码行数:31,代码来源:login.php

示例6: tryProviderSession

 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;
 }
开发者ID:JBeezygit,项目名称:e107,代码行数:40,代码来源:user_model.php

示例7: wsl_get_list_connected_providers

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();
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:13,代码来源:wsl.user.data.php

示例8: isUserLogged

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;
}
开发者ID:alexchitoraga,项目名称:tunet_casti,代码行数:20,代码来源:functions.php

示例9: __construct

 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();
 }
开发者ID:karanikn,项目名称:php-addressbook,代码行数:78,代码来源:login.inc.php


注:本文中的Hybrid_Auth::getConnectedProviders方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。