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)); }
public function loginAction() { \Hybrid_Endpoint::process(); }
/** * @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; }
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('/'); }
public function indexAction() { ob_start(); echo "<pre>"; print_r(\Hybrid_Endpoint::process()); exit; ob_end_flush(); }
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(); }
/** * 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(); }
public function getAuth() { try { \Hybrid_Endpoint::process(); } catch (\Exception $e) { // redirect back to http://URL/social/ //return Redirect::to('social'); } return; }
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; } } }
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; }
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 } }
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> "; }
/** * 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()); } }
/** * Endpoint method * * @return void */ public function endpoint() { $this->request->session()->start(); \Hybrid_Endpoint::process(); }
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; }
/** * Hybrid authentication endpoint */ public function endpoint() { log_message('debug', 'controllers.HAuth.endpoint called.'); log_message('info', 'controllers.HAuth.endpoint: $_REQUEST: ' . print_r($_REQUEST, TRUE)); if ($_SERVER['REQUEST_METHOD'] === 'GET') { log_message('debug', 'controllers.HAuth.endpoint: the request method is GET, copying REQUEST array into GET array.'); $_GET = $_REQUEST; } log_message('debug', 'controllers.HAuth.endpoint: loading the original HybridAuth endpoint script.'); //require_once APPPATH.'/third_party/hybridauth/index.php'; Hybrid_Endpoint::process(); }
/** * action endpoint * * @return void */ public function endpointAction() { \Hybrid_Endpoint::process(); }
/** * HybridAuth endpoint. */ public function indexAction() { \Hybrid_Endpoint::process(); }
<?php /*! * HybridAuth * http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth * (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html */ // ------------------------------------------------------------------------ // HybridAuth End Point // ------------------------------------------------------------------------ require_once "Hybrid/Auth.php"; require_once "Hybrid/Endpoint.php"; Hybrid_Endpoint::process();
/** * Action for URL that Hybrid_Auth redirects to when coming back from providers. * Calls Hybrid_Auth to process login. */ public function actionCallback() { require dirname(__FILE__) . '/../Hybrid/Endpoint.php'; Hybrid_Endpoint::process(); }
/** * Fires the hybridauth endpoint */ private function endpoint() { global $_CB_framework; /** @noinspection PhpIncludeInspection */ require_once( $_CB_framework->getCfg( 'absolute_path' ) . '/components/com_comprofiler/plugin/user/plug_cbconnect/hybridauth/Endpoint.php' ); Hybrid_Endpoint::process( $this->getInput()->asArray() ); }
<?php /** * Created by PhpStorm. * User: user * Date: 2015-09-24 * Time: 22:27 */ require_once __DIR__ . '/vendor/autoload.php'; $endpoint = new Hybrid_Endpoint(); $endpoint->process();
/** * */ public static function process() { self::init(); \Hybrid_Endpoint::process(); exit; }
/** * hybridauth url * * @Route("/hauth", name="contact_hauth") * @param Request $request * @return Response */ public function hauthAction(Request $request) { require_once $this->get('kernel')->getRootDir() . '/../vendor/hybridauth/hybridauth/hybridauth/Hybrid/Auth.php'; require_once $this->get('kernel')->getRootDir() . '/../vendor/hybridauth/hybridauth/hybridauth/Hybrid/Endpoint.php'; \Hybrid_Endpoint::process(); return new Response(''); }
function getTwitter() { $auth = Config::get('hybridauth'); $config = array("base_url" => URL::to('user/twitter'), "providers" => array("Twitter" => array("enabled" => true, "keys" => array("key" => $auth['providers']['Twitter']['keys']['key'], "secret" => $auth['providers']['Twitter']['keys']['secret'])))); if (isset($_REQUEST['hauth_start']) || isset($_REQUEST['hauth_done'])) { Hybrid_Endpoint::process(); } $socialAuth = new Hybrid_Auth($config); $provider = $socialAuth->authenticate("Twitter"); $userProfile = $provider->getUserProfile(); $provider->logout(); $user = User::where('email', '=', $userProfile->email)->first(); return self::autoSignin($user); }
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'))); } }
public static function processAuthDone() { WSL_Hybrid_Endpoint::authInit(); try { parent::processAuthDone(); } catch (Exception $e) { WSL_Hybrid_Endpoint::dieError("410 Gone", $e->getMessage() . "<br />For more information refer to WSL <a href='http://miled.github.io/wordpress-social-login/troubleshooting.html' target='_blank'>Troubleshooting</a>"); } }
public static function authInit() { if (!Hybrid_Endpoint::$initDone) { Hybrid_Endpoint::$initDone = TRUE; # Init Hybrid_Auth try { if (!class_exists("Hybrid_Storage")) { require_once realpath(dirname(__FILE__)) . "/Storage.php"; } $storage = new Hybrid_Storage(); // Check if Hybrid_Auth session already exist if (!$storage->config("CONFIG")) { throw new Hybrid_Exception("You cannot access this page directly."); } Hybrid_Auth::initialize($storage->config("CONFIG")); } catch (Exception $e) { Hybrid_Logger::error("Endpoint: Error while trying to init Hybrid_Auth: " . $e->getMessage()); throw new Hybrid_Exception("Oophs. Error!"); } } }
public static function authInit() { if (!Hybrid_Endpoint::$initDone) { Hybrid_Endpoint::$initDone = TRUE; // Start a new session if (!session_id()) { session_start(); } # Init Hybrid_Auth try { // Check if Hybrid_Auth session already exist if (!isset($_SESSION["HA::CONFIG"])) { header("HTTP/1.0 404 Not Found"); die("You cannot access this page directly."); } Hybrid_Auth::initialize(unserialize($_SESSION["HA::CONFIG"])); } catch (Exception $e) { Hybrid_Logger::error("Endpoint: Error while trying to init Hybrid_Auth"); header("HTTP/1.0 404 Not Found"); die("Oophs. Error!"); } } }
public static function authInit() { if (!Hybrid_Endpoint::$initDone) { Hybrid_Endpoint::$initDone = TRUE; # Init Hybrid_Auth try { require_once realpath(dirname(__FILE__)) . "/Storage.php"; $storage = new Hybrid_Storage(); // Check if Hybrid_Auth session already exist if (!$storage->config("CONFIG")) { header("HTTP/1.0 404 Not Found"); die("You cannot access this page directly."); } Hybrid_Auth::initialize($storage->config("CONFIG")); } catch (Exception $e) { Hybrid_Logger::error("Endpoint: Error while trying to init Hybrid_Auth"); header("HTTP/1.0 404 Not Found"); die("Oophs. Error!"); } } }