Skip to content
Snippets Groups Projects
Commit 104cb215 authored by Olav Morken's avatar Olav Morken
Browse files

Auth/Default: Add logout helper function

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@937 44740490-163a-0410-bde0-09ae8108e29a
parent 5f8d62c8
No related branches found
No related tags found
No related merge requests found
......@@ -109,6 +109,55 @@ class SimpleSAML_Auth_Default {
SimpleSAML_Utilities::redirect($url, $info);
}
/**
* Start logout.
*
* This function starts a logout operation from the current authentication source. This function
* never returns.
*
* @param string $returnURL The URL we should redirect the user to after logging out.
*/
public static function initLogout($returnURL) {
assert('is_string($returnURL)');
$state = array(
'SimpleSAML_Auth_Default.ReturnURL' => $returnURL,
'LogoutCompletedHandler' => array(get_class(), 'logoutCompleted'),
);
$session = SimpleSAML_Session::getInstance();
$authId = $session->getAuthority();
$session->doLogout();
$as = SimpleSAML_Auth_Source::getById($authId);
if ($as === NULL) {
/* The authority wasn't an authentication source... */
self::logoutCompleted($state);
}
$as->logout($state);
self::logoutCompleted($state);
}
/**
* Called when logout operation completes.
*
* This function never returns.
*
* @param array $state The state after the logout.
*/
public static function logoutCompleted($state) {
assert('is_array($state)');
assert('array_key_exists("SimpleSAML_Auth_Default.ReturnURL", $state)');
$returnURL = $state['SimpleSAML_Auth_Default.ReturnURL'];
/* Redirect... */
SimpleSAML_Utilities::redirect($returnURL);
}
}
?>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment