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


PHP Hybrid_Auth类代码示例

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


在下文中一共展示了Hybrid_Auth类的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));
 }
开发者ID:netfox01,项目名称:exprime,代码行数:18,代码来源:AuthController.php

示例2: 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;
 }
开发者ID:venne,项目名称:hybridauth-module,代码行数:17,代码来源:AbstractLogin.php

示例3: 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('/');
 }
开发者ID:noikiy,项目名称:Secure-Authentication-System-Laravel,代码行数:29,代码来源:LoginController.php

示例4: _init

function _init()
{
    require_once "Hybrid/Auth.php";
    if (isset($_GET['_login'])) {
        switch ($_GET['_login']) {
            case 'tw':
                break;
            case 'fb':
                break;
            case 'gp':
                break;
        }
    }
    $config = dirname(__FILE__) . '/config.php';
    try {
        $hybridauth = new Hybrid_Auth($config);
        $twitter = $hybridauth->authenticate("Google");
        $user_profile = $twitter->getUserProfile();
        echo "Hi there! " . $user_profile->displayName;
        $twitter->setUserStatus("Hello world!");
        $user_contacts = $twitter->getUserContacts();
    } catch (Exception $e) {
        echo "Ooophs, we got an error: " . $e->getMessage();
    }
}
开发者ID:gpsidhuu,项目名称:alphaReputation,代码行数:25,代码来源:logi.php

示例5: oauth_init

/**
 * plugin initialization
 */
function oauth_init()
{
    global $conf, $page, $hybridauth_conf, $template;
    load_language('plugin.lang', OAUTH_PATH);
    $conf['oauth'] = safe_unserialize($conf['oauth']);
    // check config
    if (defined('IN_ADMIN')) {
        if (empty($hybridauth_conf) and strpos(@$_GET['page'], 'plugin-oAuth') === false) {
            $page['warnings'][] = '<a href="' . OAUTH_ADMIN . '">' . l10n('Social Connect: You need to configure the credentials') . '</a>';
        }
        if (!function_exists('curl_init')) {
            $page['warnings'][] = l10n('Social Connect: PHP Curl extension is needed');
        }
    }
    // in case of registration aborded
    if (script_basename() == 'index' and ($oauth_id = pwg_get_session_var('oauth_new_user')) !== null) {
        pwg_unset_session_var('oauth_new_user');
        if ($oauth_id[0] == 'Persona') {
            oauth_assign_template_vars(get_gallery_home_url());
            $template->block_footer_script(null, 'navigator.id.logout();');
        } else {
            require_once OAUTH_PATH . 'include/hybridauth/Hybrid/Auth.php';
            try {
                $hybridauth = new Hybrid_Auth($hybridauth_conf);
                $adapter = $hybridauth->getAdapter($oauth_id[0]);
                $adapter->logout();
            } catch (Exception $e) {
            }
        }
    }
}
开发者ID:lcorbasson,项目名称:Piwigo-Social-Connect,代码行数:34,代码来源:main.inc.php

示例6: provider_login

 public function provider_login()
 {
     $setting = $this->session->data['social_login_free'];
     $server = isset($_SERVER['HTTPS']) ? HTTPS_SERVER : HTTP_SERVER;
     if (!isset($setting['base_url_index'])) {
         $setting['base_url_index'] = false;
     }
     if ($setting['base_url_index']) {
         $setting['base_url'] = $this->url->link('module/social_login_free/hybridauth', '', 'SSL');
     } else {
         $setting['base_url'] = $server . 'catalog/model/social_login_free/hybridauth.php';
     }
     $setting['debug_file'] = DIR_SYSTEM . "logs/social_login_free.txt";
     if (isset($this->request->get['provider'])) {
         $this->session->data['provider'] = $this->request->get['provider'];
     }
     $profile = array();
     require_once DIR_APPLICATION . "model/social_login_free/hybrid/auth.php";
     try {
         $hybridauth = new Hybrid_Auth($setting);
         $provider = $hybridauth->authenticate($this->session->data['provider']);
         //get the user profile
         $profile = $provider->getUserProfile();
         $this->register($this->session->data['provider'], (array) $profile);
         $provider->logout();
     } catch (Exception $e) {
         switch ($e->getCode()) {
             case 0:
                 $json['error'] = "Unspecified error.";
                 break;
             case 1:
                 $json['error'] = "Hybriauth configuration error.";
                 break;
             case 2:
                 $json['error'] = "Provider not properly configured.";
                 break;
             case 3:
                 $json['error'] = "Unknown or disabled provider.";
                 break;
             case 4:
                 $json['error'] = "Missing provider application credentials.";
                 break;
             case 5:
                 $json['error'] = "Authentification failed. " . "The user has canceled the authentication or the provider refused the connection.";
                 break;
             case 6:
                 $json['error'] = "User profile request failed. Most likely the user is not connected " . "to the provider and he should authenticate again.";
                 $provider->logout();
             case 7:
                 $json['error'] = "User not connected to the provider.";
                 $provider->logout();
             case 8:
                 $json['error'] = "Provider does not support this feature.";
                 break;
         }
         //echo "Ooophs, we got an error: " . $e->getMessage();
         $this->session->data['success'] = $json['error'] . " Ooophs, we got an error: " . $e->getMessage();
         $this->response->redirect(urldecode($this->url->link('account/login', '')));
     }
 }
开发者ID:mirzavu,项目名称:clothfarm,代码行数:60,代码来源:social_login_free.php

示例7: action_login

 public function action_login()
 {
     //if user loged in redirect home
     if (Auth::instance()->logged_in()) {
         Auth::instance()->login_redirect();
     }
     Social::include_vendor();
     $user = FALSE;
     $config = Social::get();
     if ($this->request->query('hauth_start') or $this->request->query('hauth_done')) {
         try {
             Hybrid_Endpoint::process($this->request->query());
         } catch (Exception $e) {
             Alert::set(Alert::ERROR, $e->getMessage());
             $this->redirect(Route::url('default'));
         }
     } else {
         $provider_name = $this->request->param('id');
         try {
             // initialize Hybrid_Auth with a given file
             $hybridauth = new Hybrid_Auth($config);
             // try to authenticate with the selected provider
             if ($provider_name == 'openid') {
                 $params = array('openid_identifier' => 'https://openid.stackexchange.com/');
             } else {
                 $params = NULL;
             }
             $adapter = $hybridauth->authenticate($provider_name, $params);
             if ($hybridauth->isConnectedWith($provider_name)) {
                 //var_dump($adapter->getUserProfile());
                 $user_profile = $adapter->getUserProfile();
             }
         } catch (Exception $e) {
             Alert::set(Alert::ERROR, __('Error: please try again!') . " " . $e->getMessage());
             $this->redirect(Route::url('default'));
         }
         //try to login the user with same provider and identifier
         $user = Auth::instance()->social_login($provider_name, $user_profile->identifier);
         //we couldnt login create account
         if ($user == FALSE) {
             $email = $user_profile->emailVerified != NULL ? $user_profile->emailVerified : $user_profile->email;
             $name = $user_profile->firstName != NULL ? $user_profile->firstName . ' ' . $user_profile->lastName : $user_profile->displayName;
             //if not email provided
             if (!Valid::email($email, TRUE)) {
                 Alert::set(Alert::INFO, __('We need your email address to complete'));
                 //redirect him to select the email to register
                 $this->redirect(Route::url('default', array('controller' => 'social', 'action' => 'register', 'id' => $provider_name)) . '?uid=' . $user_profile->identifier . '&name=' . $name);
             } else {
                 //register the user in DB
                 Model_User::create_social($email, $name, $provider_name, $user_profile->identifier);
                 //log him in
                 Auth::instance()->social_login($provider_name, $user_profile->identifier);
             }
         } else {
             Alert::set(Alert::SUCCESS, __('Welcome!'));
         }
         $this->redirect(Session::instance()->get_once('auth_redirect', Route::url('default')));
     }
 }
开发者ID:JeffPedro,项目名称:project-garage-sale,代码行数:59,代码来源:social.php

示例8: logout

 public function logout()
 {
     $oauth = new \Hybrid_Auth(base_path() . '/app/config/fb_Auth.php');
     $oauth->logoutAllProviders();
     Session::flush();
     Auth::logout();
     return Redirect::to("home");
 }
开发者ID:olax,项目名称:epetitions,代码行数:8,代码来源:LoginController.php

示例9: 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');
 }
开发者ID:juanjolainez,项目名称:SecondLife,代码行数:8,代码来源:FacebookManager.php

示例10: 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');
 }
开发者ID:juanjolainez,项目名称:SecondLife,代码行数:9,代码来源:TwitterManager.php

示例11: login

 public function login()
 {
     $hybridauth = new Hybrid_Auth($this->config->item('social'));
     $provider = ucfirst($this->uri->segment(3));
     $adapter = $hybridauth->authenticate('Facebook');
     $user_profile = $adapter->getUserProfile();
     echo "<pre>";
     print_r($user_profile);
     echo "</pre>";
 }
开发者ID:tinapc,项目名称:sortable,代码行数:10,代码来源:hybridauth.php

示例12: authenticate

 /**
  * @param $provider
  * @return \Hybrid_Provider_Adapter
  */
 public static function authenticate($provider)
 {
     self::init();
     $adapter = null;
     try {
         $hybridauth = new \Hybrid_Auth(self::getConfiguration());
         $provider = @trim(strip_tags($provider));
         $adapter = $hybridauth->authenticate($provider);
     } catch (\Exception $e) {
         \Logger::info($e);
     }
     return $adapter;
 }
开发者ID:rolandstoll,项目名称:pimcore,代码行数:17,代码来源:HybridAuth.php

示例13: getUser

 private function getUser($provider)
 {
     try {
         $oauth = new \Hybrid_Auth(app_path('../config/hybridauth.php'));
         $providerAuth = $oauth->authenticate($provider);
         $profile = $providerAuth->getUserProfile();
         $user = User::loginWithSocialNetwork($providerAuth, $profile, $oauth->getSessionData(), true);
         $token = $user->setHidden($user->loginHidden);
         return ['user' => $user];
     } catch (\Exception $e) {
         return ['error' => $e->getMessage()];
     }
 }
开发者ID:juanjolainez,项目名称:SecondLife,代码行数:13,代码来源:ApiController.php

示例14: process

 public function process()
 {
     $user_profile = array();
     //if( !empty( $_GET["action"] ) && $_GET["action"] == 'auth' && !empty($_GET["service"]) ) {
     if ($provider = $this->getProperty('provider', false)) {
         try {
             $config = $this->modx->modHybridAuth->getProvidersConfig();
             $hybridauth = new Hybrid_Auth($config);
             $adapter = $hybridauth->authenticate($provider);
             $user_profile = $adapter->getUserProfile();
         } catch (Exception $e) {
             $error = "<b>got an error!</b> " . $e->getMessage();
             $this->modx->log(xPDO::LOG_LEVEL_ERROR, '[modHybridAuth] ' . $error);
             $url = $this->modx->makeUrl($this->getProperty('failure_page'), null, null, 'full');
             $this->modx->sendRedirect($url);
         }
         // Check is loggedin
         if ($this->modx->user->hasSessionContext($this->modx->context->key)) {
             $redirectTo = $this->modx->getOption('site_url');
             $this->modx->sendRedirect($redirectTo);
             return;
         }
         // else
         // 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" => $user_profile->identifier, "Provider.name" => $provider, "modUser.active" => 1, "Profile.blocked" => 0));
         $q->limit(1);
         //$q->prepare();
         //$this->modx->log(1, $q->toSQL());
         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 return to redirect
         if ($redirect_id = $this->getProperty('redirect_id') and $redirect_url = $this->modx->makeUrl($redirect_id)) {
             $this->modx->sendRedirect($redirect_url);
             return;
         }
     } else {
         $response = $this->modx->runProcessor('web/endpoint', $this->getProperties(), array('processors_path' => $this->modx->modHybridAuth->getOption('processorsPath')));
         return $response->getResponse();
     }
     return '';
 }
开发者ID:Tramp1357,项目名称:atlasorg,代码行数:49,代码来源:auth.class.php

示例15: getFacebook

 public function getFacebook($auth = null)
 {
     if ($auth = 'auth') {
         try {
             Hybri_Endpoint::process();
         } catch (Exception $e) {
             return Redirect::to('fbauth');
         }
         return;
     }
     $oauth = new Hybrid_Auth(app_path() . '/config/fbauth.php');
     $provider = $oauth->authenticate('Facebook');
     $profile = $provider->getUserProfile();
     return var_dump($profile) . '<a href="logout">Logout</a>';
 }
开发者ID:aaffio,项目名称:guide,代码行数:15,代码来源:userController.php


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