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

Remove file name from logout handler registration. Also add a check for an

invalid logout handler.

The file name should no longer be neccesary, as the files should now be
loaded by the autoloader.


git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@609 44740490-163a-0410-bde0-09ae8108e29a
parent 7763d0ee
No related branches found
No related tags found
No related merge requests found
...@@ -457,12 +457,20 @@ class SimpleSAML_Session { ...@@ -457,12 +457,20 @@ class SimpleSAML_Session {
/** /**
* This function registers a logout handler. * This function registers a logout handler.
* *
* @param $file The file which contains the logout handler.
* @param $classname The class which contains the logout handler. * @param $classname The class which contains the logout handler.
* @param $functionname The logout handler function. * @param $functionname The logout handler function.
*/ */
public function registerLogoutHandler($file, $classname, $functionname) { public function registerLogoutHandler($classname, $functionname) {
$this->logout_handlers[] = array('file' => $file, 'class' => $classname, 'function' => $functionname);
$logout_handler = array($classname, $functionname);
if(!is_callable($logout_handler)) {
throw new Exception('Logout handler is not a vaild function: ' . $classname . '::' .
$functionname);
}
$this->logout_handlers[] = $logout_handler;
$this->dirty = TRUE; $this->dirty = TRUE;
} }
...@@ -473,13 +481,20 @@ class SimpleSAML_Session { ...@@ -473,13 +481,20 @@ class SimpleSAML_Session {
private function callLogoutHandlers() { private function callLogoutHandlers() {
foreach($this->logout_handlers as $handler) { foreach($this->logout_handlers as $handler) {
/* Load the file with the logout handler. */ $logout_handler = array($classname, $functionname);
require_once((isset($SIMPLESAML_INCPREFIX)?$SIMPLESAML_INCPREFIX:'') . $handler['file']);
/* Verify that the logout handler is a valid function. */
if(!is_callable($logout_handler)) {
$classname = $logout_handler[0];
$functionname = $logout_handler[1];
throw new Exception('Logout handler is not a vaild function: ' . $classname . '::' .
$functionname);
}
/* Call the logout handler. */ /* Call the logout handler. */
$classname = $handler['class']; call_user_func($logout_handler);
$functionname = $handler['function'];
call_user_func(array($classname, $functionname));
} }
/* We require the logout handlers to register themselves again if they want to be called later. */ /* We require the logout handlers to register themselves again if they want to be called later. */
......
...@@ -94,7 +94,7 @@ try { ...@@ -94,7 +94,7 @@ try {
$memcache->set($sessionID, $data); $memcache->set($sessionID, $data);
/* Register logout handler. */ /* Register logout handler. */
$session->registerLogoutHandler('SimpleSAML/AuthMemCookie.php', 'SimpleSAML_AuthMemCookie', 'logoutHandler'); $session->registerLogoutHandler('SimpleSAML_AuthMemCookie', 'logoutHandler');
/* Redirect the user back to this page to signal that the login is completed. */ /* Redirect the user back to this page to signal that the login is completed. */
SimpleSAML_Utilities::redirect(SimpleSAML_Utilities::selfURL()); SimpleSAML_Utilities::redirect(SimpleSAML_Utilities::selfURL());
......
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