Revision: 2015
Author: olavmrk
Date: Wed Dec  2 03:52:09 2009
Log: Add no-cookie page and helper function.
http://code.google.com/p/simplesamlphp/source/detail?r=2015

Added:
  /trunk/modules/core/dictionaries/no_cookie.php
  /trunk/modules/core/templates/no_cookie.tpl.php
  /trunk/modules/core/www/no_cookie.php
Modified:
  /trunk/lib/SimpleSAML/Utilities.php

=======================================
--- /dev/null
+++ /trunk/modules/core/dictionaries/no_cookie.php      Wed Dec  2 03:52:09 2009
@@ -0,0 +1,24 @@
+<?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',
+       ),
+
+);
+
+
+?>
=======================================
--- /dev/null
+++ /trunk/modules/core/templates/no_cookie.tpl.php     Wed Dec  2 03:52:09 2009
@@ -0,0 +1,22 @@
+<?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');
=======================================
--- /dev/null
+++ /trunk/modules/core/www/no_cookie.php       Wed Dec  2 03:52:09 2009
@@ -0,0 +1,12 @@
+<?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();
=======================================
--- /trunk/lib/SimpleSAML/Utilities.php Thu Nov 26 01:17:50 2009
+++ /trunk/lib/SimpleSAML/Utilities.php Wed Dec  2 03:52:09 2009
@@ -2198,6 +2198,29 @@
                throw new SimpleSAML_Error_Exception('You need to set 
\'authority\' in  
the metadata for ' .
                        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);
+       }

  }

--

You received this message because you are subscribed to the Google Groups 
"simpleSAMLphp commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/simplesamlphp-commits?hl=en.


Reply via email to