From eb002f5b1fa8486b686f42304b63adfa1b13a4aa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no>
Date: Fri, 6 Feb 2009 09:52:40 +0000
Subject: [PATCH] Redirect the user if refreshing the login page and the
 session is lost (without entering credentials). Will improve user experience

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1246 44740490-163a-0410-bde0-09ae8108e29a
---
 modules/core/www/loginuserpass.php | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/modules/core/www/loginuserpass.php b/modules/core/www/loginuserpass.php
index aa21292e6..87ccb70dc 100644
--- a/modules/core/www/loginuserpass.php
+++ b/modules/core/www/loginuserpass.php
@@ -15,6 +15,15 @@ if (!array_key_exists('AuthState', $_REQUEST)) {
 }
 $authStateId = $_REQUEST['AuthState'];
 
+try {
+	/* Retrieve the authentication state. */
+	$state = SimpleSAML_Auth_State::loadState($authStateId, sspmod_core_Auth_UserPassBase::STAGEID);
+} catch(Exception $e) {
+	if (array_key_exists('SessionLostURL', $_REQUEST)) {
+		SimpleSAML_Utilities::redirect($_REQUEST['SessionLostURL']);
+	}
+}
+
 if (array_key_exists('username', $_REQUEST)) {
 	$username = $_REQUEST['username'];
 } else {
-- 
GitLab