本文整理汇总了PHP中Hybrid_Auth::setup方法的典型用法代码示例。如果您正苦于以下问题:PHP Hybrid_Auth::setup方法的具体用法?PHP Hybrid_Auth::setup怎么用?PHP Hybrid_Auth::setup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hybrid_Auth
的用法示例。
在下文中一共展示了Hybrid_Auth::setup方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
}
示例2: getAdapter
/**
* Return the adapter instance for an authenticated provider
*/
public static function getAdapter($providerId = NULL)
{
Hybrid_Logger::info("Enter Hybrid_Auth::getAdapter( {$providerId} )");
return Hybrid_Auth::setup($providerId);
}
示例3: processAuthDone
/**
* define:endpoint step 3.1 and 3.2
*/
public static function processAuthDone()
{
Hybrid_Endpoint::authInit();
$provider_id = trim(strip_tags(Hybrid_Endpoint::$request["hauth_done"]));
$hauth = Hybrid_Auth::setup($provider_id);
if (!$hauth) {
Hybrid_Logger::error("Endpoint: Invalide parameter on hauth_done!");
$hauth->adapter->setUserUnconnected();
header("HTTP/1.0 404 Not Found");
die("Invalide parameter! Please return to the login page and try again.");
}
try {
Hybrid_Logger::info("Endpoint: call adapter [{$provider_id}] loginFinish() ");
$hauth->adapter->loginFinish();
} catch (Exception $e) {
Hybrid_Logger::error("Exception:" . $e->getMessage(), $e);
Hybrid_Error::setError($e->getMessage(), $e->getCode(), $e->getTraceAsString(), $e);
$hauth->adapter->setUserUnconnected();
}
Hybrid_Logger::info("Endpoint: job done. retrun to callback url.");
$hauth->returnToCallbackUrl();
die;
}
示例4: str_replace
Hybrid_Logger::error("Exception:" . $e->getMessage(), $e);
Hybrid_Error::setError($e->getMessage(), $e->getCode(), $e->getTraceAsString(), $e);
$hauth->returnToCallbackUrl();
}
die;
}
# define:endpoint step 3.1 and 3.2
if (isset($_REQUEST["hauth_done"]) && $_REQUEST["hauth_done"]) {
// Fix a strange behavior when some provider call back ha endpoint
// with /index.php?hauth.done={provider}?{args}...
if (strrpos($_SERVER["QUERY_STRING"], '?')) {
$_SERVER["QUERY_STRING"] = str_replace("?", "&", $_SERVER["QUERY_STRING"]);
parse_str($_SERVER["QUERY_STRING"], $_REQUEST);
}
$provider_id = trim(strip_tags($_REQUEST["hauth_done"]));
$hauth = Hybrid_Auth::setup($provider_id);
if (!$hauth) {
Hybrid_Logger::error("Endpoint: Invalide parameter on hauth_done!");
$hauth->adapter->setUserUnconnected();
header("HTTP/1.0 404 Not Found");
die("Invalide parameter! Please return to the login page and try again.");
}
try {
Hybrid_Logger::info("Endpoint: call adapter [{$provider_id}] loginFinish() ");
$hauth->adapter->loginFinish();
} catch (Exception $e) {
Hybrid_Logger::error("Exception:" . $e->getMessage(), $e);
Hybrid_Error::setError($e->getMessage(), $e->getCode(), $e->getTraceAsString(), $e);
$hauth->adapter->setUserUnconnected();
}
Hybrid_Logger::info("Endpoint: job done. retrun to callback url.");
示例5: init
public function init()
{
if (!e107::getPref('social_login_active', false)) {
return;
}
$this->adapter = null;
$providerId = $this->_provider;
if ($providerId && Hybrid_Auth::isConnectedWith($providerId)) {
$this->adapter = Hybrid_Auth::setup($providerId);
}
}
示例6: processAuthDone
/**
* define:endpoint step 3.1 and 3.2
*/
public static function processAuthDone()
{
Hybrid_Endpoint::authInit();
// Fix a strange behavior when some provider call back ha endpoint
// with /index.php?hauth.done={provider}?{args}...
if (strrpos($_SERVER["QUERY_STRING"], '?')) {
$_SERVER["QUERY_STRING"] = str_replace("?", "&", $_SERVER["QUERY_STRING"]);
parse_str($_SERVER["QUERY_STRING"], Hybrid_Endpoint::$request);
}
$provider_id = trim(strip_tags(Hybrid_Endpoint::$request["hauth_done"]));
$hauth = Hybrid_Auth::setup($provider_id);
if (!$hauth) {
Hybrid_Logger::error("Endpoint: Invalide parameter on hauth_done!");
$hauth->adapter->setUserUnconnected();
header("HTTP/1.0 404 Not Found");
die("Invalide parameter! Please return to the login page and try again.");
}
try {
Hybrid_Logger::info("Endpoint: call adapter [{$provider_id}] loginFinish() ");
$hauth->adapter->loginFinish();
} catch (Exception $e) {
Hybrid_Logger::error("Exception:" . $e->getMessage(), $e);
Hybrid_Error::setError($e->getMessage(), $e->getCode(), $e->getTraceAsString(), $e);
$hauth->adapter->setUserUnconnected();
}
Hybrid_Logger::info("Endpoint: job done. retrun to callback url.");
$hauth->returnToCallbackUrl();
die;
}
示例7: processAuthDone
/**
* Define: endpoint step 3.1 and 3.2
* @return void
* @throws Hybrid_Exception
*/
protected function processAuthDone()
{
$this->authInit();
$provider_id = trim(strip_tags($this->request["hauth_done"]));
$hauth = Hybrid_Auth::setup($provider_id);
if (!$hauth) {
Hybrid_Logger::error("Endpoint: Invalid parameter on hauth_done!");
$hauth->adapter->setUserUnconnected();
throw new Hybrid_Exception("Invalid parameter! Please return to the login page and try again.");
}
try {
Hybrid_Logger::info("Endpoint: call adapter [{$provider_id}] loginFinish() ");
$hauth->adapter->loginFinish();
} catch (Exception $e) {
Hybrid_Logger::error("Exception:" . $e->getMessage(), $e);
Hybrid_Error::setError($e->getMessage(), $e->getCode(), $e->getTraceAsString(), $e->getPrevious());
$hauth->adapter->setUserUnconnected();
}
Hybrid_Logger::info("Endpoint: job done. return to callback url.");
$hauth->returnToCallbackUrl();
die;
}
示例8: processAuthDone
/**
* define:endpoint step 3.1 and 3.2
*/
protected function processAuthDone()
{
$provider_id = trim($this->getProperty('hauth_done'));
$hauth = Hybrid_Auth::setup($provider_id);
if (!$hauth) {
Hybrid_Logger::error("Endpoint: Invalid parameter on hauth_done!");
$hauth->adapter->setUserUnconnected();
header("HTTP/1.0 404 Not Found");
return "Invalid parameter! Please return to the login page and try again.";
}
try {
Hybrid_Logger::info("Endpoint: call adapter [{$provider_id}] loginFinish() ");
$hauth->adapter->loginFinish();
} catch (Exception $e) {
Hybrid_Logger::error("Exception:" . $e->getMessage(), $e);
Hybrid_Error::setError($e->getMessage(), $e->getCode(), $e->getTraceAsString(), $e);
$hauth->adapter->setUserUnconnected();
}
Hybrid_Logger::info("Endpoint: job done. retrun to callback url.");
// Save profile data in session
$profile = $hauth->adapter->getUserProfile();
// Try to get user by social profile
/*$q = $this->modx->newQuery('modUser');
$q->innerJoin('modUserProfile', 'Profile');
$q->innerJoin('modHybridAuthUserProfile', 'SocialProfile');
$q->innerJoin('modHybridAuthProvider', 'Provider', "Provider.id=SocialProfile.provider");
$q->where(array(
"SocialProfile.identifier" => $profile->identifier,
"Provider.name" => $provider,
"modUser.active" => 1,
"Profile.blocked" => 0,
));
$q->limit(1);
if($user = $this->modx->getObject('modUser', $q)){
$user->addSessionContext($this->modx->context->key);
$redirectTo = $this->modx->getOption('site_url');
$this->modx->sendRedirect($redirectTo);
return;
}*/
// else
$_SESSION['social_profile'] = array('provider' => $provider_id, 'profile' => $this->modx->error->toArray($profile));
//$q->prepare();
//$this->modx->log(1, $q->toSQL());
// else
$hauth->returnToCallbackUrl();
return '';
}
示例9: getAdapter
/**
* Return the adapter instance for an authenticated provider
*/
public static function getAdapter($providerId = NULL)
{
if (!Hybrid_Auth::$store) {
require_once realpath(dirname(__FILE__)) . "/Storage.php";
Hybrid_Auth::$store = new Hybrid_Storage();
}
if (!Hybrid_Auth::$config) {
Hybrid_Auth::initialize(Hybrid_Auth::storage()->config("CONFIG"));
}
return Hybrid_Auth::setup($providerId);
}
示例10: processAuthDone
/**
* define:endpoint step 3.1 and 3.2
*/
public static function processAuthDone()
{
Hybrid_Endpoint::authInit();
$provider_id = trim(strip_tags(Hybrid_Endpoint::$request["hauth_done"]));
# check if page accessed directly
if (!Hybrid_Auth::storage()->get("hauth_session.{$provider_id}.hauth_endpoint")) {
throw new Hybrid_Exception("You cannot access this page directly.");
}
$hauth = Hybrid_Auth::setup($provider_id);
if (!$hauth) {
$hauth->adapter->setUserUnconnected();
throw new Hybrid_Exception("Invalid parameter! Please return to the login page and try again.");
}
try {
$hauth->adapter->loginFinish();
} catch (Exception $e) {
Hybrid_Error::setError($e->getMessage(), $e->getCode());
$hauth->adapter->setUserUnconnected();
}
$hauth->returnToCallbackUrl();
die;
}
示例11: processAuthDone
/**
* define:endpoint step 3.1 and 3.2
*/
protected function processAuthDone()
{
$provider_id = trim($this->getProperty('hauth_done'));
$hauth = Hybrid_Auth::setup($provider_id);
if (!$hauth) {
Hybrid_Logger::error("Endpoint: Invalid parameter on hauth_done!");
$hauth->adapter->setUserUnconnected();
header("HTTP/1.0 404 Not Found");
return "Invalid parameter! Please return to the login page and try again.";
}
try {
Hybrid_Logger::info("Endpoint: call adapter [{$provider_id}] loginFinish() ");
$hauth->adapter->loginFinish();
} catch (Exception $e) {
Hybrid_Logger::error("Exception:" . $e->getMessage(), $e);
Hybrid_Error::setError($e->getMessage(), $e->getCode(), $e->getTraceAsString(), $e);
$hauth->adapter->setUserUnconnected();
}
Hybrid_Logger::info("Endpoint: job done. retrun to callback url.");
// Save profile data in session
$profile = $hauth->adapter->getUserProfile();
// else
$_SESSION['social_profile'] = array('provider' => $provider_id, 'profile' => $this->modx->error->toArray($profile));
//$q->prepare();
//$this->modx->log(1, $q->toSQL());
// else
$hauth->returnToCallbackUrl();
return '';
}