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

ProcessingChain: Add support for returning to a function.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1659 44740490-163a-0410-bde0-09ae8108e29a
parent 4fdb5187
No related branches found
No related tags found
No related merge requests found
...@@ -160,8 +160,10 @@ class SimpleSAML_Auth_ProcessingChain { ...@@ -160,8 +160,10 @@ class SimpleSAML_Auth_ProcessingChain {
* Process the given state. * Process the given state.
* *
* This function will only return if processing completes. If processing requires showing * This function will only return if processing completes. If processing requires showing
* a page to the user, we will redirect to the URL set in $state['ReturnURL'] after processing is * a page to the user, we will not be able to return from this function. There are two ways
* completed. * this can be handled:
* - Redirect to an URL: We will redirect to the URL set in $state['ReturnURL'].
* - Call a function: We will call the function set in $state['ReturnCall'].
* *
* If an exception is thrown during processing, it should be handled by the caller of * If an exception is thrown during processing, it should be handled by the caller of
* this function. If the user has redirected to a different page, the exception will be * this function. If the user has redirected to a different page, the exception will be
...@@ -176,7 +178,8 @@ class SimpleSAML_Auth_ProcessingChain { ...@@ -176,7 +178,8 @@ class SimpleSAML_Auth_ProcessingChain {
*/ */
public function processState(&$state) { public function processState(&$state) {
assert('is_array($state)'); assert('is_array($state)');
assert('array_key_exists("ReturnURL", $state)'); assert('array_key_exists("ReturnURL", $state) || array_key_exists("ReturnCall", $state)');
assert('!array_key_exists("ReturnURL", $state) || !array_key_exists("ReturnCall", $state)');
$state[self::FILTERS_INDEX] = $this->filters; $state[self::FILTERS_INDEX] = $this->filters;
...@@ -233,15 +236,34 @@ class SimpleSAML_Auth_ProcessingChain { ...@@ -233,15 +236,34 @@ class SimpleSAML_Auth_ProcessingChain {
} }
} }
assert('array_key_exists("ReturnURL", $state)'); /* Completed. */
assert('array_key_exists("ReturnURL", $state) || array_key_exists("ReturnCall", $state)');
assert('!array_key_exists("ReturnURL", $state) || !array_key_exists("ReturnCall", $state)');
/* Completed. Save state information, and redirect to the URL specified if (array_key_exists('ReturnURL', $state)) {
* in $state['ReturnURL']. /*
*/ * Save state information, and redirect to the URL specified
$id = SimpleSAML_Auth_State::saveState($state, self::COMPLETED_STAGE); * in $state['ReturnURL'].
SimpleSAML_Utilities::redirect($state['ReturnURL'], array(self::AUTHPARAM => $id)); */
$id = SimpleSAML_Auth_State::saveState($state, self::COMPLETED_STAGE);
SimpleSAML_Utilities::redirect($state['ReturnURL'], array(self::AUTHPARAM => $id));
} else {
/* Pass the state to the function defined in $state['ReturnCall']. */
/* We are done with the state array in the session. Delete it. */
SimpleSAML_Auth_State::deleteState($state);
$func = $state['ReturnCall'];
assert('is_callable($func)');
call_user_func($func, $state);
assert(FALSE);
}
} }
/** /**
* Process the given state passivly. * Process the given state passivly.
* *
......
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