本文整理汇总了PHP中Hybrid_Auth::storage方法的典型用法代码示例。如果您正苦于以下问题:PHP Hybrid_Auth::storage方法的具体用法?PHP Hybrid_Auth::storage怎么用?PHP Hybrid_Auth::storage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hybrid_Auth
的用法示例。
在下文中一共展示了Hybrid_Auth::storage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUser
public static function getUser($token)
{
$config = \Config::get('hybridauth');
$socialAuth = new \Hybrid_Auth($config);
$socialAuth->storage()->set("hauth_session.facebook.is_logged_in", 1);
$socialAuth->storage()->set("hauth_session.facebook.token.access_token", $token);
return SocialLoginManager::getUser('facebook');
}
示例2: getUser
public static function getUser($token, $secret)
{
$config = \Config::get('hybridauth');
$socialAuth = new \Hybrid_Auth($config);
$socialAuth->storage()->set("hauth_session.twitter.is_logged_in", 1);
$socialAuth->storage()->set("hauth_session.twitter.token.access_token", $token);
$socialAuth->storage()->set("hauth_session.twitter.token.access_token_secret", $secret);
return SocialLoginManager::getUser('twitter');
}
示例3: loginFinish
/**
* finish login step
*/
function loginFinish()
{
parent::loginFinish();
$this->user->profile->emailVerified = $this->user->profile->email;
// restore the user profile
Hybrid_Auth::storage()->set("hauth_session.{$this->providerId}.user", $this->user);
}
示例4: loginFinish
/**
* finish login step
*/
function loginFinish()
{
parent::loginFinish();
$uid = str_replace("http://steamcommunity.com/openid/id/", "", $this->user->profile->identifier);
if ($uid) {
$data = @file_get_contents("http://steamcommunity.com/profiles/{$uid}/?xml=1");
$data = @new SimpleXMLElement($data);
if (!is_object($data)) {
return false;
}
$this->user->profile->displayName = (string) $data->{'steamID'};
$this->user->profile->photoURL = (string) $data->{'avatarMedium'};
$this->user->profile->description = (string) $data->{'summary'};
$realname = (string) $data->{'realname'};
if ($realname) {
$this->user->profile->displayName = $realname;
}
$customURL = (string) $data->{'customURL'};
if ($customURL) {
$this->user->profile->profileURL = "http://steamcommunity.com/id/{$customURL}/";
}
// restore the user profile
Hybrid_Auth::storage()->set("hauth_session.{$this->providerId}.user", $this->user);
}
}
示例5: getUserProfile
/**
* load the user profile from the IDp api client
*/
function getUserProfile()
{
// refresh tokens if needed
$this->refreshToken();
// Vkontakte requires user id, not just token for api access
$params['uid'] = Hybrid_Auth::storage()->get("hauth_session.{$this->providerId}.user_id");
$params['fields'] = 'first_name,last_name,nickname,screen_name,sex,bdate,timezone,photo_rec,photo_big';
// ask vkontakte api for user infos
$response = $this->api->api("https://api.vk.com/method/getProfiles", 'GET', $params);
if (!isset($response->response[0]) || !isset($response->response[0]->uid) || isset($response->error)) {
throw new Exception("User profile request failed! {$this->providerId} returned an invalid response.", 6);
}
$response = $response->response[0];
$this->user->profile->identifier = property_exists($response, 'uid') ? $response->uid : "";
$this->user->profile->firstName = property_exists($response, 'first_name') ? $response->first_name : "";
$this->user->profile->lastName = property_exists($response, 'last_name') ? $response->last_name : "";
$this->user->profile->displayName = property_exists($response, 'nickname') ? $response->nickname : "";
$this->user->profile->photoURL = property_exists($response, 'photo_big') ? $response->photo_big : "";
$this->user->profile->profileURL = property_exists($response, 'screen_name') ? "http://vk.com/" . $response->screen_name : "";
if (property_exists($response, 'sex')) {
switch ($response->sex) {
case 1:
$this->user->profile->gender = 'female';
break;
case 2:
$this->user->profile->gender = 'male';
break;
default:
$this->user->profile->gender = '';
break;
}
}
return $this->user->profile;
}
示例6: loginFinish
/**
* finish login step
*/
function loginFinish()
{
parent::loginFinish();
$this->user->profile->profileURL = $this->user->profile->identifier;
// https://ru.wargaming.net/id/5069690-Steel_Master/
$this->user->profile->identifier = preg_replace('/^[^0-9]+([0-9]+)-.+$/', '$1', $this->user->profile->identifier);
// restore the user profile
Hybrid_Auth::storage()->set("hauth_session.{$this->providerId}.user", $this->user);
}
示例7: loginFinish
/**
* finish login step
*/
function loginFinish()
{
if (!$_REQUEST['dr_auth_code']) {
throw new Exception('Authentication failed! ' . $this->providerId . ' returned an invalid Token and Verifier.', 5);
}
$this->token('access_token', $_REQUEST['dr_auth_code']);
// set user as logged in
$this->setUserConnected();
Hybrid_Auth::storage()->set("hauth_session.{$this->providerId}.user", $this->user);
}
示例8: loginFinish
function loginFinish()
{
parent::loginFinish();
$this->user->profile->identifier = str_ireplace("http://steamcommunity.com/openid/id/", "", $this->user->profile->identifier);
if (!$this->user->profile->identifier) {
throw new Exception("Authentication failed! {$this->providerId} returned an invalid user ID.", 5);
}
// If API key is not provided, use legacy API methods
if (!empty($this->config['keys']['key'])) {
$this->getUserProfileWebAPI($this->config['keys']['key']);
} else {
$this->getUserProfileLegacyAPI();
}
Hybrid_Auth::storage()->set("hauth_session.{$this->providerId}.user", $this->user);
}
示例9: loginFinish
/**
* finish login step
*/
function loginFinish()
{
parent::loginFinish();
$this->user->profile->identifier = str_ireplace("http://steamcommunity.com/openid/id/", "", $this->user->profile->identifier);
if (!$this->user->profile->identifier) {
throw new Exception("Authentication failed! {$this->providerId} returned an invalid user ID.", 5);
}
// if api key is provided, we attempt to use steam web api
if (isset(Hybrid_Auth::$config['providers']['Steam']['keys']['key']) && Hybrid_Auth::$config['providers']['Steam']['keys']['key']) {
$userProfile = $this->getUserProfileWebAPI(Hybrid_Auth::$config['providers']['Steam']['keys']['key']);
} else {
$userProfile = $this->getUserProfileLegacyAPI();
}
// fetch user profile
foreach ($userProfile as $k => $v) {
$this->user->profile->{$k} = $v ? $v : $this->user->profile->{$k};
}
// store user profile
Hybrid_Auth::storage()->set("hauth_session.{$this->providerId}.user", $this->user);
}
示例10: getUserProfile
/**
* load the user profile from the IDp api client
*/
function getUserProfile()
{
// refresh tokens if needed
$this->refreshToken();
// Vkontakte requires user id, not just token for api access
$params['uid'] = Hybrid_Auth::storage()->get("hauth_session.{$this->providerId}.user_id");
$params['fields'] = implode(',', $this->fields);
// ask vkontakte api for user infos
$response = $this->api->api('getProfiles', 'GET', $params);
if (!isset($response->response[0]) || !isset($response->response[0]->uid) || isset($response->error)) {
throw new Exception("User profile request failed! {$this->providerId} returned an invalid response.", 6);
}
// Fill datas
$response = reset($response->response);
foreach ($this->getUserByResponse($response, true) as $k => $v) {
$this->user->profile->{$k} = $v;
}
// Additional data
$this->user->profile->email = Hybrid_Auth::storage()->get("hauth_session.{$this->providerId}.user_email");
return $this->user->profile;
}
示例11: clearTokens
/**
* clear all existen tokens for this provider
*/
public function clearTokens()
{
Hybrid_Auth::storage()->deleteMatch("hauth_session.{$this->providerId}.");
}
示例12: get_option
` account to completely end your session.</p>
<a class="button" href="<?php
echo $url;
?>
" ><span>Continue</span></a>
</div>
</body>
<?php
} else {
if (!empty($provider)) {
$SocialAuth_WP_providers = get_option('SocialAuth_WP_providers');
if (is_array($SocialAuth_WP_providers) && count($SocialAuth_WP_providers)) {
$config = array();
if (isset($SocialAuth_WP_providers[$provider])) {
$config["base_url"] = plugin_dir_url(__FILE__) . 'hybridauth/';
$config["providers"] = array();
//this si same as orig config, no need to amke config again
$config["providers"][$provider] = $SocialAuth_WP_providers[$provider];
} else {
echo "Current Provider is unknowun to system.";
exit;
}
$config["providers"][$provider] = $HA_PROVIDER_CONFIG['providers'][$provider];
require_once dirname(__FILE__) . "/hybridauth/Hybrid/Auth.php";
$hybridauth = new Hybrid_Auth($config);
Hybrid_Auth::storage()->delete("hauth_session.{$provider}.is_logged_in");
}
}
$a = preg_replace("/amp\\;/", "", $a);
header('Location: ' . $a);
}
示例13: returnToCallbackUrl
/**
* Redirect the user to hauth_return_to (the callback url)
* @return void
*/
function returnToCallbackUrl()
{
// get the stored callback url
$callback_url = Hybrid_Auth::storage()->get("hauth_session.{$this->id}.hauth_return_to");
// if the user presses the back button in the browser and we already deleted the hauth_return_to from
// the session in the previous request, we will redirect to '/' instead of displaying a blank page.
if (!$callback_url) {
$callback_url = '/';
}
// remove some unneeded stored data
Hybrid_Auth::storage()->delete("hauth_session.{$this->id}.hauth_return_to");
Hybrid_Auth::storage()->delete("hauth_session.{$this->id}.hauth_endpoint");
Hybrid_Auth::storage()->delete("hauth_session.{$this->id}.id_provider_params");
// back to home
Hybrid_Auth::redirect($callback_url);
}
示例14: getApiError
/**
* return api error
*/
public static function getApiError()
{
return Hybrid_Auth::storage() ? Hybrid_Auth::storage()->get("hauth_session.error.apierror") : '';
}
示例15: function
$app->get('/api/languages', 'getLanguages');
// for add page..
$app->get('/api/partsofspeech', 'getPartsOfSpeech');
// for add page..
$app->get('/api/bins/', 'getBins');
// for bins page
$app->get('/api/icons/:word', function ($word) use($app, $model) {
echo $model->getIcons($word);
});
// not working on live server
$app->post('/api/u/words', $authenticate($app), function () use($app, $model) {
$session_identifier = Hybrid_Auth::storage()->get('user');
echo $model->getMyWords($session_identifier);
});
$app->post('/api/u/bins', $authenticate($app), function () use($app, $model) {
$session_identifier = Hybrid_Auth::storage()->get('user');
echo $model->getMyBins($session_identifier);
});
$app->run();
// POST to api/add/word
function addWord()
{
$app = \Slim\Slim::getInstance();
$request = $app->request();
$data = json_decode($request->getBody());
$i = 0;
// To get each WordID[$i]
foreach ($data->words as $word) {
// Insert word into words table
$sql_words = "INSERT INTO `words` (`Word`, `Gender`, `Case`, `Infinitive`, `Aspect`, `Conjugation`, `Person`, `Number`, `IconID`, `IconAuthor`, `IconTerm`, `Timestamp`, `Salt`) VALUES (:word, NULL, NULL, NULL, NULL, NULL, NULL, NULL, :iconID, :iconAuthor, :iconTerm, CURRENT_TIMESTAMP, :salt);";
try {