本文整理汇总了PHP中Hybrid_Auth::hasSession方法的典型用法代码示例。如果您正苦于以下问题:PHP Hybrid_Auth::hasSession方法的具体用法?PHP Hybrid_Auth::hasSession怎么用?PHP Hybrid_Auth::hasSession使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hybrid_Auth
的用法示例。
在下文中一共展示了Hybrid_Auth::hasSession方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: socialAction
public function socialAction()
{
// hack to import all GLOBAL_HYBRID_ into global namespace
foreach (token_get_all(file_get_contents(APPLICATION_PATH . '/../hybridauth/hybridauth.php')) as $token) {
if ($token[0] == T_VARIABLE) {
$var = substr($token[1], 1);
if (strstr($var, 'GLOBAL_HYBRID_AUTH_') !== FALSE) {
global ${$var};
}
}
}
require_once APPLICATION_PATH . '/../hybridauth/hybridauth.php';
$hauth = new Hybrid_Auth();
if ($hauth->hasError()) {
var_dump($hauth->getErrorMessage());
exit;
}
if (!$hauth->hasSession()) {
$adapter = $hauth->setup($this->_getParam('provider'), array('hauth_return_to' => 'http:///auth/social/provider/' . $this->_getParam('provider')));
$adapter->login();
} else {
$adapter = $hauth->wakeup();
$userData = $adapter->user();
$adapter = $this->_helper->service('auth.adapter.social');
$adapter->setProvider($userData->providerId)->setProviderUserId($userData->providerUID);
$result = $this->auth->authenticate($adapter);
if ($result->getCode() == Zend_Auth_Result::SUCCESS) {
$this->_helper->redirector('index', 'dashboard');
}
$this->_forward('social', 'register', 'default', array('userData' => $userData));
}
}