logoutAllProviders() public static method

A generic function to logout all connected provider at once
public static logoutAllProviders ( ) : void
return void
示例#1
0
 public function logout()
 {
     $oauth = new \Hybrid_Auth(base_path() . '/app/config/fb_Auth.php');
     $oauth->logoutAllProviders();
     Session::flush();
     Auth::logout();
     return Redirect::to("home");
 }
 /**
  * Destroys all sessions
  *
  * @return void
  */
 function Logout()
 {
     if (is_object($this->Hybrid_Auth)) {
         $this->Hybrid_Auth->logoutAllProviders();
     }
     $logout_data = array();
     if (!empty($this->config['loginContext'])) {
         $logout_data['login_context'] = $this->config['loginContext'];
     }
     if (!empty($this->config['addContexts'])) {
         $logout_data['add_contexts'] = $this->config['addContexts'];
     }
     $response = $this->modx->runProcessor('security/logout', $logout_data);
     if ($response->isError()) {
         $this->modx->log(modX::LOG_LEVEL_ERROR, '[HybridAuth] logout error. Username: '******'username') . ', uid: ' . $this->modx->user->get('id') . '. Message: ' . implode(', ', $response->getAllErrors()));
         $_SESSION['HA']['error'] = implode(', ', $response->getAllErrors());
     }
     unset($_SESSION['HA::CONFIG']);
     $this->Refresh('logout');
 }
示例#3
0
            }
        }
    } catch (Exception $e) {
        echo $e->getMessage();
    }
});
$app->get('/:add', $authenticate($app), function () use($app, $model) {
    $session_identifier = Hybrid_Auth::storage()->get('user');
    $avatarUrl = $model->getAvatarUrl($session_identifier);
    $app->render('add.php', ['datajs' => 'words.js', 'datagroupjs' => 'words-io.js', 'name' => 'Add Word', 'model' => $model, 'avatarURL' => $avatarUrl, 'identifier' => $session_identifier, 'scriptID' => 'i']);
})->conditions(array('add' => '[+]'));
// moved to words page. remove soon
$app->get('/logout/', function () use($app, $model) {
    $app->hybridInstance;
    $model->logout_user();
    Hybrid_Auth::logoutAllProviders();
    $app->redirect('/login/');
});
$app->get('/welcome/', $authenticate($app, $model), function () use($app, $model) {
    $session_identifier = Hybrid_Auth::storage()->get('user');
    $avatarUrl = $model->getAvatarUrl($session_identifier);
    $app->render('welcome.php', ['datajs' => 'welcome', 'datagroupjs' => 'account', 'name' => 'Welcome', 'model' => $model, 'avatarURL' => $avatarUrl, 'identifier' => $session_identifier, 'scriptID' => 'i']);
});
$app->get('/words/', $authenticate($app, $model), function () use($app, $model) {
    $session_identifier = Hybrid_Auth::storage()->get('user');
    $avatarUrl = $model->getAvatarUrl($session_identifier);
    $app->render('words.php', ['datajs' => 'words.js', 'datagroupjs' => 'words-io.js', 'name' => 'Words', 'model' => $model, 'avatarURL' => $avatarUrl, 'identifier' => $session_identifier, 'scriptID' => 'i']);
});
$app->get('/bins/', $authenticate($app, $model), function () use($app, $model) {
    $session_identifier = Hybrid_Auth::storage()->get('user');
    $avatarUrl = $model->getAvatarUrl($session_identifier);
<?php

// config and whatnot
$config = dirname(__FILE__) . '/../../hybridauth/config.php';
require_once "../../hybridauth/Hybrid/Auth.php";
try {
    $hybridauth = new Hybrid_Auth($config);
    // logout the user from $provider
    $hybridauth->logoutAllProviders();
    // return to login page
    $hybridauth->redirect("login.php");
} catch (Exception $e) {
    echo "<br /><br /><b>Oh well, we got an error :</b> " . $e->getMessage();
    echo "<hr /><h3>Trace</h3> <pre>" . $e->getTraceAsString() . "</pre>";
}
 /**
  * Logout all providers
  *
  * @param \Cake\Event\Event $event Event.
  * @param array $user The user about to be logged out.
  * @return void
  */
 public function logout(Event $event, array $user)
 {
     $this->_init($this->_registry->getController()->request);
     $this->hybridAuth->logoutAllProviders();
 }
示例#6
0
 function logoutwith($provider = NULL)
 {
     $this->autoRender = false;
     require_once WWW_ROOT . 'hybridauth/Hybrid/Auth.php';
     $hybridauth_config = array("base_url" => 'http://' . $_SERVER['HTTP_HOST'] . $this->base . "/hybridauth/", "providers" => array("Facebook" => array("enabled" => true, "keys" => array("id" => "your_fb_api_key", "secret" => "fb_api_secret"), "scope" => 'email'), "Twitter" => array("enabled" => true, "keys" => array("key" => "CSpbRJK5eAEod91O7js5Gg", "secret" => "8KGhKpPzYRDX6FYkPVXTzvELN1D7pXtA78SYSnq44"))));
     try {
         // create an instance for Hybridauth with the configuration file path as parameter
         $hybridauth = new Hybrid_Auth($hybridauth_config);
         // try to authenticate the selected $provider
         $adapter = $hybridauth->logoutAllProviders();
         // grab the user profile
     } catch (Exception $e) {
         // Display the recived error
         switch ($e->getCode()) {
             case 0:
                 $error = "Unspecified error.";
                 break;
             case 1:
                 $error = "Hybriauth configuration error.";
                 break;
             case 2:
                 $error = "Provider not properly configured.";
                 break;
             case 3:
                 $error = "Unknown or disabled provider.";
                 break;
             case 4:
                 $error = "Missing provider application credentials.";
                 break;
             case 5:
                 $error = "Authentification failed. The user has canceled the authentication or the provider refused the connection.";
                 break;
             case 6:
                 $error = "User profile request failed. Most likely the user is not connected to the provider and he should to authenticate again.";
                 $adapter->logout();
                 break;
             case 7:
                 $error = "User not connected to the provider.";
                 $adapter->logout();
                 break;
         }
         // well, basically you should not display this to the end user, just give him a hint and move on..
         $error .= "Original error message: " . $e->getMessage();
         $error .= "Trace: " . $e->getTraceAsString();
         $this->set('error', $error);
     }
 }
 public function logout(\Hybrid_Auth $hybridAuth)
 {
     $hybridAuth->logoutAllProviders();
     // TODO: Return to the index page
 }
    $guzzle->delete($app->config['db_name'] . '/' . $id . '?rev=' . $rev);
    return $app->redirect($app["url_generator"]->generate('index') . '#manage');
})->before($authenticate);
// login handler
// check if authenticated against provider
// retrieve user email address and save to session
$app->get('/login', function () use($app, $auth) {
    $google = $auth->authenticate("Google");
    $currentUser = $google->getUserProfile();
    $_SESSION['uid'] = $currentUser->email;
    return $app->redirect($app["url_generator"]->generate('index') . '#search');
})->bind('login');
// logout handler
// log out and display logout information page
$app->get('/logout', function () use($app, $auth) {
    $auth->logoutAllProviders();
    session_destroy();
    return $app['twig']->render('logout.twig');
})->before($authenticate);
// OAuth callback handler
$app->get('/callback', function () {
    return Hybrid_Endpoint::process();
});
// legal page
$app->get('/legal', function () use($app) {
    return $app['twig']->render('legal.twig');
});
// delete-my-data handler
$app->get('/delete-my-data', function () use($app, $guzzle) {
    $uid = $_SESSION['uid'];
    // get all docs for user
示例#9
0
function userLogOut() {
	$GLOBALS['userIsLoggedIn'] = false;

	unset($_SESSION['authentication_info']);
	Hybrid_Auth::logoutAllProviders();

	Db_Users::logout();
}
示例#10
0
 /**
  * Log the user out of the application.
  *
  */
 public function getLogout()
 {
     Confide::logout();
     try {
         // Logout all providers
         $socialAuth = new Hybrid_Auth(app_path() . '/config/hybridauth.php');
         $socialAuth->logoutAllProviders();
     } catch (Exception $err) {
         var_dump($err);
     }
     return Redirect::to('/');
 }
示例#11
0
function logoutExternal()
{
    global $CFG;
    $hybridauth_config = $CFG->dirAddress . 'core/lib/hybridauth-2.4.1/hybridauth/config.php';
    require_once $CFG->dirAddress . 'core/lib/hybridauth-2.4.1/hybridauth/Hybrid/Auth.php';
    try {
        $hybridauth = new Hybrid_Auth($hybridauth_config);
        $hybridauth->logoutAllProviders();
    } catch (Exception $e) {
        //echo "<br /><br /><b>Oh well, we got an error :</b> " . $e->getMessage();
        //echo "<hr /><h3>Trace</h3> <pre>" . $e->getTraceAsString() . "</pre>";
    }
}
    try {
        $hybridauth = new Hybrid_Auth($config);
        $adapter = $hybridauth->authenticate($mod);
        $user_profile = $adapter->getUserProfile();
        //?
        //			$adapter->disconnect();
        if ($mod == "tumblr") {
            $full_user_profile = $adapter->api()->api('user/info');
        }
    } catch (Exception $e) {
        $reclaim_error = "" . $e->getMessage();
    }
} elseif (isset($mod) && !$login) {
    try {
        $hybridauth = new Hybrid_Auth($config);
        $adapter = $hybridauth->logoutAllProviders($mod);
        $user_profile = '';
        $_SESSION['login'] = 0;
        $reclaim_error = 'logged out user from ' . $mod . '.';
    } catch (Exception $e) {
        $reclaim_error = "" . $e->getMessage();
    }
}
// logged in ?
if (!isset($user_profile) || empty($user_profile)) {
    // return error
    if (!isset($reclaim_error)) {
        $reclaim_error = 'got no user profile from ' . $mod . '.';
    }
    $_SESSION['e'] = $reclaim_error;
    //echo "".$reclaim_error;
示例#13
0
 /**
  * Log the user out of the application.
  *
  */
 public function getLogout()
 {
     Confide::logout();
     try {
         // Logout all providers
         $socialAuth = new Hybrid_Auth(app_path() . '/config/hybridauth.php');
         $socialAuth->logoutAllProviders();
     } catch (Exception $err) {
         Log::error($err);
         return Redirect::to('/')->with('notice', $err->getMessage());
     }
     return Redirect::to('/');
 }
示例#14
0
 /**
  * User authorization
  * Registers new user when authorizing via HybridAuth
  * Updates user details while logging via HybridAuth when email matches a registered user
  */
 public function authorize()
 {
     $this->iaCore->startHook('phpCoreBeforeAuth');
     $authorized = 0;
     if (isset($_POST['register'])) {
         $login = '';
     } elseif (isset($_POST['username'])) {
         $login = $_POST['username'];
         $authorized++;
     } else {
         $login = '';
     }
     if (isset($_POST['register'])) {
         $pass = '';
     } elseif (isset($_POST['password'])) {
         $pass = $_POST['password'];
         $authorized++;
     } else {
         $pass = '';
     }
     $isBackend = iaCore::ACCESS_ADMIN == $this->iaCore->getAccessType();
     if (IA_EXIT && $authorized != 2) {
         // use this hook to logout
         $this->iaCore->startHook('phpUserLogout', array('userInfo' => iaUsers::getIdentity(true)));
         if ($this->iaCore->get('hybrid_enabled')) {
             require_once IA_INCLUDES . 'hybrid/Auth.php';
             Hybrid_Auth::logoutAllProviders();
         }
         iaUsers::clearIdentity();
         unset($_SESSION['_achkych']);
         if (strpos($_SERVER['HTTP_REFERER'], $this->iaView->domainUrl) === 0) {
             if ($isBackend) {
                 $_SESSION['IA_EXIT'] = true;
             }
             $url = $isBackend ? IA_ADMIN_URL : IA_URL;
             header('Location: ' . $url);
         } else {
             header('Location: ' . $this->iaView->domainUrl . ($isBackend ? $this->iaCore->get('admin_page') . IA_URL_DELIMITER : ''));
         }
         exit;
     } elseif ($authorized == 2 && $login && $pass) {
         $auth = (bool) $this->getAuth(null, $login, $pass, isset($_POST['remember']));
         $this->iaCore->startHook('phpUserLogin', array('userInfo' => iaUsers::getIdentity(true), 'password' => $pass));
         if (!$auth) {
             if ($isBackend) {
                 $this->iaView->assign('error_login', true);
             } else {
                 $this->iaView->setMessages(iaLanguage::get('error_login'));
                 $this->iaView->name('login');
             }
         } else {
             unset($_SESSION['_achkych']);
             if (isset($_SESSION['referrer'])) {
                 header('Location: ' . $_SESSION['referrer']);
                 unset($_SESSION['referrer']);
                 exit;
             } else {
                 if ($isBackend) {
                     $this->iaCore->factory('log')->write(iaLog::ACTION_LOGIN, array('ip' => $this->iaCore->util()->getIp(false)));
                 }
             }
         }
     } elseif (2 == $authorized) {
         if ($isBackend) {
             $this->iaView->assign('empty_login', true);
         } else {
             $this->iaView->setMessages(iaLanguage::get('empty_login'));
             $this->iaView->name('login');
         }
     } elseif (isset($_COOKIE[self::AUTO_LOGIN_COOKIE_NAME])) {
         $this->_checkAutoLoginCookie();
     }
     $this->iaCore->getSecurityToken() || ($_SESSION[iaCore::SECURITY_TOKEN_MEMORY_KEY] = $this->iaCore->factory('util')->generateToken(92));
 }
示例#15
0
 /**
  * Log the user out with all providers.
  * 
  * @return void
  */
 public function logout()
 {
     $this->hybrid->logoutAllProviders();
 }