From f05eb4bf196bb49ad11b7cc6885eac1d0de957b7 Mon Sep 17 00:00:00 2001
From: Olimpia Magliulo <olimpiam@intern-ikts-MacBook-Air.local>
Date: Tue, 7 Nov 2017 14:15:43 +0100
Subject: [PATCH] Fix a problem when trying to change language after a login
 error

Fix: Missing AuthState parameter when trying to retrieve the authentication state.
---
 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 38cdcc9b4..99be03f97 100644
--- a/modules/core/www/loginuserpass.php
+++ b/modules/core/www/loginuserpass.php
@@ -76,7 +76,16 @@ if (!empty($_REQUEST['username']) || !empty($password)) {
 		/* Login failed. Extract error code and parameters, to display the error. */
 		$errorCode = $e->getErrorCode();
 		$errorParams = $e->getParameters();
+		$state['error']= array(
+		    'code' => $errorCode,
+            'params' => $errorParams
+        );
+        $authStateId = SimpleSAML_Auth_State::saveState($state, sspmod_core_Auth_UserPassBase::STAGEID);
+        $queryParams = array('AuthState' => $authStateId);
 	}
+	if (isset($state['error'])){
+	    unset($state['error']);
+    }
 }
 
 $globalConfig = SimpleSAML_Configuration::getInstance();
-- 
GitLab