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


PHP Hybrid_Auth::authenticate方法代码示例

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


在下文中一共展示了Hybrid_Auth::authenticate方法的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: 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> ";
 }
开发者ID:olax,项目名称:epetitions,代码行数:19,代码来源:LoginController.php

示例5: 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());
     }
 }
开发者ID:derickp,项目名称:swag,代码行数:23,代码来源:MainController.php

示例6: 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
     }
 }
开发者ID:JonTheNiceGuy,项目名称:cchits.laravel,代码行数:44,代码来源:LoginController.php

示例7: auth

 /**
  * Prompt the User to authenticate with a social-auth provider
  *
  * @param $provider_name
  * @param null $profile
  * @return null
  */
 public function auth($provider_name, &$profile = null)
 {
     $identifier = null;
     try {
         $provider = $this->hybrid_auth->authenticate($provider_name);
         $userProfile = $provider->getUserProfile();
         $identifier = $userProfile->identifier;
         $profile = $userProfile;
     } catch (\Exception $e) {
         dd($e->getMessage());
     }
     return $identifier;
 }
开发者ID:ipunkt,项目名称:social-auth,代码行数:20,代码来源:SocialRegisterController.php

示例8: 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

示例9: _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

示例10: authenticate

 /**
  * Authenticate a user based on the request information.
  *
  * @param Request $request Request to get authentication information from.
  * @param Response $response A response object that can have headers added.
  * @return array|bool User array on success, false on failure.
  */
 public function authenticate(Request $request, Response $response)
 {
     $fields = $this->_config['fields'];
     if (!$request->data($fields['provider'])) {
         return $this->getUser($request);
     }
     $provider = $this->_checkFields($request, $fields);
     if (!$provider) {
         return false;
     }
     if ($this->_config['hauth_return_to']) {
         $returnTo = Router::url($this->_config['hauth_return_to'], true);
     } else {
         $returnTo = Router::url(['plugin' => 'ADmad/HybridAuth', 'controller' => 'HybridAuth', 'action' => 'authenticated'], true);
     }
     $params = ['hauth_return_to' => $returnTo];
     if ($provider === 'OpenID') {
         $params['openid_identifier'] = $request->data[$fields['openid_identifier']];
     }
     $this->_init($request);
     $adapter = $this->hybridAuth->authenticate($provider, $params);
     if ($adapter) {
         return $this->_getUser($provider, $adapter);
     }
     return false;
 }
开发者ID:jamiefifty,项目名称:CakePHP-HybridAuth,代码行数:33,代码来源:HybridAuthAuthenticate.php

示例11: 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

示例12: 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

示例13: login

 public function login($network = '')
 {
     $this->network = $network;
     $this->setContentType("text/plain");
     $this->setRedirectUrl();
     $this->setPopupCallback();
     $config = $this->get_hybrid_auth_config();
     $hybridauth = new Hybrid_Auth($config);
     if ($this->network == 'facebook') {
         $this->auth = $hybridauth->authenticate("Facebook");
     } elseif ($this->network == 'linkedin') {
         $this->auth = $hybridauth->authenticate("LinkedIn");
     } elseif ($this->network == 'twitter') {
         $this->auth = $hybridauth->authenticate("Twitter");
     } elseif ($this->network == 'google') {
         $this->auth = $hybridauth->authenticate("Google");
     } else {
         $this->redirect('/');
     }
     $is_user_logged_in = $this->auth->isUserConnected();
     $this->user = $this->auth->getUserProfile();
     $u = new User();
     if ($u->checkLogin()) {
         $this->setProfile();
     } else {
         if (!$this->do_login()) {
             if ($this->do_register()) {
                 if ($this->do_login()) {
                     $this->setProfile();
                 }
             }
         }
     }
     if ($popupCallback = $this->getPopupCallback()) {
         $this->setContentType('text/html');
         $this->set('popupCallback', $popupCallback);
     } else {
         $this->externalRedirect($this->getRedirectUrl());
     }
 }
开发者ID:remo,项目名称:social,代码行数:40,代码来源:controller.php

示例14: 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

示例15: authenticate

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


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