public static function clearSession() { $storage = new MrClay_CookieStorage(array('secret' => UserConfig::$SESSION_SECRET, 'mode' => MrClay_CookieStorage::MODE_ENCRYPT, 'path' => UserConfig::$SITEROOTURL)); $storage->delete(UserConfig::$session_userid_key); }
require_once dirname(__FILE__) . '/config.php'; require_once dirname(__FILE__) . '/User.php'; $current_user = User::get(); $oauth_user_id = null; try { if (!array_key_exists('module', $_GET)) { throw new Exception('module not specified'); } if (!array_key_exists('oauth_token', $_GET) || !array_key_exists('oauth_verifier', $_GET)) { throw new Exception('oauth_token & oauth_varifier required'); } $module = AuthenticationModule::get($_GET['module']); $storage = new MrClay_CookieStorage(array('secret' => UserConfig::$SESSION_SECRET, 'mode' => MrClay_CookieStorage::MODE_ENCRYPT, 'path' => UserConfig::$SITEROOTURL, 'httponly' => true)); $oauth_user_id = $storage->fetch(UserConfig::$oauth_user_id_key); $storage->delete(UserConfig::$oauth_user_id_key); if (is_null($oauth_user_id)) { throw new Exception("can't determine OAuth User ID"); } try { $module->getAccessToken($oauth_user_id); } catch (OAuthException2 $e) { throw new Exception('problem getting access token: ' . $e->getMessage()); } try { $identity = $module->getIdentity($oauth_user_id); } catch (OAuthException2 $e) { throw new Exception('problem getting user identity: ' . $e->getMessage()); } if (is_null($identity)) { throw new Exception('no identity returned');