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

Add no-cookie page and helper function.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2015 44740490-163a-0410-bde0-09ae8108e29a
parent c0ce3f02
No related branches found
No related tags found
No related merge requests found
......@@ -2199,6 +2199,29 @@ class SimpleSAML_Utilities {
var_export($idpmetadata['entityid'], TRUE) . '.');
}
/**
* Check for session cookie, and show missing-cookie page if it is missing.
*
* @param string|NULL $retryURL The URL the user should access to retry the operation.
*/
public static function checkCookie($retryURL = NULL) {
assert('is_string($retryURL) || is_null($retryURL)');
$session = SimpleSAML_Session::getInstance();
if ($session->hasSessionCookie()) {
return;
}
/* We didn't have a session cookie. Redirect to the no-cookie page. */
$url = SimpleSAML_Module::getModuleURL('core/no_cookie.php');
if ($retryURL !== NULL) {
$url = SimpleSAML_Utilities::addURLParameter($url, array('retryURL' => $retryURL));
}
SimpleSAML_Utilities::redirect($url);
}
}
?>
\ No newline at end of file
<?php
/*
* Not yet in translation portal.
*/
$lang = array(
'header' => array (
'no' => 'Mangler informasjonskapsel',
'en' => 'Missing cookie',
),
'description' => array (
'no' => 'Du ser ut til å ha deaktivert informasjonskapsler. Kontroller innstillingene i nettleseren din og prøv igjen.',
'en' => 'You appear to have disabled cookies in your browser. Please check the settings in your browser, and try again.',
),
'retry' => array (
'no' => 'Prøv igjen',
'en' => 'Retry',
),
);
?>
\ No newline at end of file
<?php
assert('array_key_exists("retryURL", $this->data)');
$retryURL = $this->data['retryURL'];
$header = htmlspecialchars($this->t('{core:no_cookie:header}'));
$description = htmlspecialchars($this->t('{core:no_cookie:description}'));
$retry = htmlspecialchars($this->t('{core:no_cookie:retry}'));
$this->data['header'] = $header;
$this->includeAtTemplateBase('includes/header.php');
echo('<h2>' . $header . '</h2>');
echo('<p>' . $description . '</p>');
if ($retryURL !== NULL) {
echo('<ul>');
echo('<li><a href="' . htmlspecialchars($retryURL) . '" id="retry">' . $retry . '</a></li>');
echo('</ul>');
}
$this->includeAtTemplateBase('includes/footer.php');
<?php
if (isset($_REQUEST['retryURL'])) {
$retryURL = (string)$_REQUEST['retryURL'];
} else {
$retryURL = NULL;
}
$globalConfig = SimpleSAML_Configuration::getInstance();
$t = new SimpleSAML_XHTML_Template($globalConfig, 'core:no_cookie.tpl.php');
$t->data['retryURL'] = $retryURL;
$t->show();
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