diff --git a/www/example-simple/authsource-example.php b/www/example-simple/authsource-example.php index 17854da3dd2d8c08d85413e73b06ebd17a5ba281..631542d5404b7de3c97489f317cac08b967ea6c9 100644 --- a/www/example-simple/authsource-example.php +++ b/www/example-simple/authsource-example.php @@ -14,6 +14,21 @@ if(array_key_exists('logout', $_REQUEST)) { SimpleSAML_Auth_Default::initLogout('/' . $config->getBaseURL() . 'logout.php'); } +if (array_key_exists(SimpleSAML_Auth_State::EXCEPTION_PARAM, $_REQUEST)) { + /* This is just a simple example of an error. */ + + $state = SimpleSAML_Auth_State::loadExceptionState(); + assert('array_key_exists(SimpleSAML_Auth_State::EXCEPTION_DATA, $state)'); + $e = $state[SimpleSAML_Auth_State::EXCEPTION_DATA]; + + header('Content-Type: text/plain'); + echo "Exception during login:\n"; + foreach ($e->format() as $line) { + echo $line . "\n"; + } + exit(0); +} + if(!array_key_exists('as', $_REQUEST)) { throw new Exception('No authentication source chosen.'); } @@ -21,7 +36,7 @@ if(!array_key_exists('as', $_REQUEST)) { $as = $_REQUEST['as']; if (!$session->isValid($as)) { - SimpleSAML_Auth_Default::initLogin($as, SimpleSAML_Utilities::selfURL()); + SimpleSAML_Auth_Default::initLogin($as, SimpleSAML_Utilities::selfURL(), SimpleSAML_Utilities::selfURL()); } $attributes = $session->getAttributes();