本文整理汇总了PHP中Hybrid_Endpoint类的典型用法代码示例。如果您正苦于以下问题:PHP Hybrid_Endpoint类的具体用法?PHP Hybrid_Endpoint怎么用?PHP Hybrid_Endpoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Hybrid_Endpoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getGoogleLogin
public function getGoogleLogin($auth = NULL)
{
if ($auth == 'auth') {
Hybrid_Endpoint::process();
}
try {
$oauth = new Hybrid_Auth(app_path() . '/config/google_auth.php');
$provider = $oauth->authenticate('Google');
$profile = $provider->getUserProfile();
} catch (exception $e) {
return $e->getMessage();
}
if ($user = User::where('email', '=', $profile->email)->first()) {
Auth::login($user, true);
return Redirect::intended('/');
}
return App::make('frontend\\UserController')->doSignUp(array('email' => $profile->email, 'login' => $profile->identifier, 'password' => "pass1234", 'f_name' => $profile->firstName, 'l_name' => $profile->lastName));
}
示例2: loginAction
public function loginAction()
{
\Hybrid_Endpoint::process();
}
示例3: createLoginProviderEntity
/**
* @return LoginProviderEntity
*/
protected function createLoginProviderEntity()
{
$type = $this->getHybridType();
//dump($this->getCallbackUrl());die($this->getCallbackUrl());
$params = array('base_url' => $this->getCallbackUrl(), 'providers' => array($type => $this->getConfig() + array('enabled' => TRUE)));
$hybridauth = new \Hybrid_Auth($params);
if (isset($_REQUEST['hauth_start']) || isset($_REQUEST['hauth_done'])) {
\Hybrid_Endpoint::process();
}
/** @var \Hybrid_User_Profile $user */
$user = $hybridauth->authenticate($this->getHybridType(), $this->authenticationParameters)->getUserProfile();
$ret = new LoginProviderEntity($user->identifier, static::getType());
return $ret;
}
示例4: loginWithSocial
public function loginWithSocial($social_provider, $action = "")
{
// check URL segment
if ($action == "auth") {
// process authentication
try {
Session::set('provider', $social_provider);
Hybrid_Endpoint::process();
} catch (Exception $e) {
// redirect back to http://URL/social/
return Redirect::route('loginWith');
}
return;
}
try {
// create a HybridAuth object
$socialAuth = new Hybrid_Auth(app_path() . '/config/hybridauth.php');
// authenticate with Provider
$provider = $socialAuth->authenticate($social_provider);
// fetch user profile
$userProfile = $provider->getUserProfile();
} catch (Exception $e) {
// exception codes can be found on HybBridAuth's web site
Session::flash('error_msg', $e->getMessage());
return Redirect::to('/login');
}
$this->createOAuthProfile($userProfile);
return Redirect::to('/');
}
示例5: indexAction
public function indexAction()
{
ob_start();
echo "<pre>";
print_r(\Hybrid_Endpoint::process());
exit;
ob_end_flush();
}
示例6: endpoint
function endpoint()
{
jimport('hs.user.lib.Hybrid.Auth');
jimport('hs.user.lib.Hybrid.Endpoint');
// require_once (JPATH_COMPONENT_SITE . '/lib/Hybrid/Auth.php');
// require_once (JPATH_COMPONENT_SITE . '/lib/Hybrid/Endpoint.php');
Hybrid_Endpoint::process();
}
示例7: processEndpoint
/**
* process the
*
* @return string
*/
public function processEndpoint()
{
//App::import('Vendor', 'hybridauth/Hybrid/Endpoint');
require_once ROOT . DS . 'vendor' . DS . 'hybridauth' . DS . 'hybridauth' . DS . 'hybridauth' . DS . 'Hybrid' . DS . 'Endpoint.php';
if (!$this->hybridauth) {
$this->init();
}
\Hybrid_Endpoint::process();
}
示例8: getAuth
public function getAuth()
{
try {
\Hybrid_Endpoint::process();
} catch (\Exception $e) {
// redirect back to http://URL/social/
//return Redirect::to('social');
}
return;
}
示例9: hybrid
public function hybrid($provider)
{
if (isset($_REQUEST['hauth_start']) || isset($_REQUEST['hauth_done'])) {
\Hybrid_Endpoint::process();
}
try {
// create an instance for Hybridauth with the configuration file path as parameter
// try to authenticate the user with twitter,
// user will be redirected to Twitter for authentication,
// if he already did, then Hybridauth will ignore this step and return an instance of the adapter
$this->provider = $this->hybrid_auth->authenticate(ucfirst($provider));
var_dump($this->provider);
die;
// get the user profile
$twitter_user_profile = $this->provider->getUserProfile();
var_dump($twitter_user_profile);
die;
$this->session->set('auth-identity', array('id' => $twitter_user_profile->identifier, 'username' => $twitter_user_profile->displayName, 'pic' => $twitter_user_profile->photoURL));
//return $this->response->redirect('');
} catch (\Exception $e) {
// Display the recived error,
// to know more please refer to Exceptions handling section on the userguide
switch ($e->getCode()) {
case 0:
echo "Unspecified error.";
break;
case 1:
echo "Hybriauth configuration error.";
break;
case 2:
echo "Provider not properly configured.";
break;
case 3:
echo "Unknown or disabled provider.";
break;
case 4:
echo "Missing provider application credentials.";
break;
case 5:
echo "Authentification failed. The user has canceled the authentication or the provider refused the connection.";
break;
case 6:
echo "User profile request failed. Most likely the user is not connected to the provider and he should authenticate again.";
$this->provider->logout();
break;
case 7:
echo "User not connected to the provider.";
$this->provider->logout();
break;
case 8:
echo "Provider does not support this feature.";
break;
}
}
}
示例10: login
public function login($account)
{
if (isset($_REQUEST['hauth_start']) || isset($_REQUEST['hauth_done'])) {
Hybrid_Endpoint::process();
}
$authAdapter = $this->service->authenticate($account);
if ($authAdapter) {
return $this->user->login($authAdapter->getUserProfile()->email);
}
return null;
}
示例11: login
public function login(\Hybrid_Auth $hybridAuth, $action = '')
{
try {
switch ($action) {
case 'auth':
\Hybrid_Endpoint::process();
return;
case 'openid-google':
$hybridAuthProvider = $hybridAuth->authenticate('openid', ['openid_identifier' => 'http://www.google.com/accounts/o8/id']);
$hybridAuthUserProfile = $hybridAuthProvider->getUserProfile();
$user = User::firstOrCreate(['authenticator' => 'openid', 'authenticator_credential' => $hybridAuthUserProfile->identifier]);
break;
case 'openid-yahoo':
$hybridAuthProvider = $hybridAuth->authenticate('openid', ['openid_identifier' => 'http://my.yahoo.com']);
$hybridAuthUserProfile = $hybridAuthProvider->getUserProfile();
$user = User::firstOrCreate(['authenticator' => 'openid', 'authenticator_credential' => $hybridAuthUserProfile->identifier]);
break;
case 'google':
$hybridAuthProvider = $hybridAuth->authenticate('google');
$hybridAuthUserProfile = $hybridAuthProvider->getUserProfile();
$user = User::firstOrCreate(['authenticator' => 'openid', 'authenticator_credential' => $hybridAuthUserProfile->identifier]);
break;
case 'facebook':
$hybridAuthProvider = $hybridAuth->authenticate('facebook');
$hybridAuthUserProfile = $hybridAuthProvider->getUserProfile();
$user = User::firstOrCreate(['authenticator' => 'facebook', 'authenticator_credential' => $hybridAuthUserProfile->identifier]);
break;
case 'twitter':
$hybridAuthProvider = $hybridAuth->authenticate('twitter');
$hybridAuthUserProfile = $hybridAuthProvider->getUserProfile();
$user = User::firstOrCreate(['authenticator' => 'twitter', 'authenticator_credential' => $hybridAuthUserProfile->identifier]);
break;
default:
$hybridAuthProvider = $hybridAuth->authenticate('openid', ['openid_identifier' => $action]);
$hybridAuthUserProfile = $hybridAuthProvider->getUserProfile();
$user = User::firstOrCreate(['authenticator' => 'openid', 'authenticator_credential' => $hybridAuthUserProfile->identifier]);
break;
}
\Session::put('userid', $user->id);
// TODO: Return to the index page
} catch (Exception $ex) {
// TODO: Return error to the login form
}
}
示例12: getLoginFacebook
public function getLoginFacebook($auth = NULL)
{
if ($auth == 'auth') {
try {
\Hybrid_Endpoint::process();
} catch (Exception $e) {
return Redirect::to("home");
}
return;
}
$config = array("base_url" => "http://laravel/public/", "providers" => array("Facebook" => array("enabled" => true, "keys" => array("id" => "488919314589569", "secret" => "2b8ab46fece7bef72c48abe0eaa664d0"), "scope" => "public_profile,email", "display" => "popup")));
$oauth = new \Hybrid_Auth($config);
$provider = $oauth->authenticate("Facebook");
$profile = $provider->getUserProfile();
var_dump($profile);
echo "FirstName:" . $profile->firstName . "<br>";
echo "Email:" . $profile->email;
echo "<br><a href='logout'>Logout</a> ";
}
示例13: hybridlogin
/**
* Login using hybrid auth.
*/
function hybridlogin($provider)
{
if (isset($_REQUEST['hauth_start']) || isset($_REQUEST['hauth_done'])) {
Hybrid_Endpoint::process();
exit;
}
$config = array("base_url" => RewriteUtil::getBaseUrl() . "main/hybridlogin?provider=" . $provider, "providers" => array());
if (isset($this->config["facebookAppId"])) {
$config["providers"]["Facebook"] = array("enabled" => true, "trustForwarded" => false, "scope" => "email", "keys" => array("id" => $this->config["facebookAppId"], "secret" => $this->config["facebookSecret"]));
}
$hybridauth = new Hybrid_Auth($config);
try {
$auth = $hybridauth->authenticate($provider);
$profile = $auth->getUserProfile();
$_SESSION["email"] = $profile->email;
$this->redirect();
} catch (Exception $e) {
$this->showLoginForm($e->getMessage());
}
}
示例14: endpoint
/**
* Endpoint method
*
* @return void
*/
public function endpoint()
{
$this->request->session()->start();
\Hybrid_Endpoint::process();
}
示例15: check_associate
function check_associate($useraccount)
{
$userid = $useraccount['userid'];
$action = null;
$key = null;
if (!empty($_REQUEST['hauth_start'])) {
$key = trim(strip_tags($_REQUEST['hauth_start']));
$action = 'process';
} else {
if (!empty($_REQUEST['hauth_done'])) {
$key = trim(strip_tags($_REQUEST['hauth_done']));
$action = 'process';
} else {
if (!empty($_GET['link'])) {
$key = trim(strip_tags($_GET['link']));
$action = 'login';
}
}
}
if ($key == null) {
return false;
}
$provider = $this->get_ha_provider($key);
$source = strtolower($provider);
if ($action == 'login') {
// handle the login
// after login come back to the same page
$loginCallback = qa_path('', array(), qa_opt('site_url'));
require_once $this->directory . 'Hybrid/Auth.php';
require_once $this->directory . 'qa-open-utils.php';
// prepare the configuration of HybridAuth
$config = $this->get_ha_config($provider, $loginCallback);
try {
// try to login
$hybridauth = new Hybrid_Auth($config);
$adapter = $hybridauth->authenticate($provider);
// if ok, create/refresh the user account
$user = $adapter->getUserProfile();
$duplicates = 0;
if (!empty($user)) {
// prepare some data
$ohandle = null;
}
$oemail = null;
if (empty($user->displayName)) {
$ohandle = $provider;
} else {
$ohandle = preg_replace('/[\\@\\+\\/]/', ' ', $user->displayName);
}
if (strlen(@$user->email) && $user->emailVerified) {
// only if email is confirmed
$oemail = $user->email;
}
$duplicate = qa_db_user_login_find_duplicate__open($source, $user->identifier);
if ($duplicate == null) {
// simply create a new login
qa_db_user_login_sync(true);
qa_db_user_login_add($userid, $source, $user->identifier);
if ($oemail) {
qa_db_user_login_set__open($source, $user->identifier, 'oemail', $oemail);
}
qa_db_user_login_set__open($source, $user->identifier, 'ohandle', $ohandle);
qa_db_user_login_sync(false);
// now that everything was added, log out to allow for multiple accounts
$adapter->logout();
// redirect to get rid of parameters
qa_redirect('logins');
} else {
if ($duplicate['userid'] == $userid) {
// trying to add the same account, just update the email/handle
qa_db_user_login_sync(true);
if ($oemail) {
qa_db_user_login_set__open($source, $user->identifier, 'oemail', $oemail);
}
qa_db_user_login_set__open($source, $user->identifier, 'ohandle', $ohandle);
qa_db_user_login_sync(false);
// log out to allow for multiple accounts
$adapter->logout();
// redirect to get rid of parameters
qa_redirect('logins');
} else {
if (qa_get('confirm') == 2) {
return $duplicate;
} else {
qa_redirect('logins', array('link' => qa_get('link'), 'confirm' => 2));
}
}
}
} catch (Exception $e) {
qa_redirect('logins', array('provider' => $provider, 'code' => $e->getCode()));
}
}
if ($action == 'process') {
require_once "Hybrid/Auth.php";
require_once "Hybrid/Endpoint.php";
Hybrid_Endpoint::process();
}
return false;
}