diff --git a/modules/core/lib/Controller/Login.php b/modules/core/lib/Controller/Login.php
index ac7a596a269c572d00e485e013faaf6c9adcc264..dc0eabdbe8baf15f4baf03eb722d5f091509233c 100644
--- a/modules/core/lib/Controller/Login.php
+++ b/modules/core/lib/Controller/Login.php
@@ -211,7 +211,7 @@ class Login
         }
 
         $t = new Template($this->config, 'core:loginuserpass.twig');
-        $t->data['stateparams'] = ['AuthState' => $authStateId];
+        $t->data['AuthState'] = $authStateId;
 
         if (array_key_exists('forcedUsername', $state)) {
             $t->data['username'] = $state['forcedUsername'];
@@ -399,7 +399,7 @@ class Login
         }
 
         $t = new Template($this->config, 'core:loginuserpass.twig');
-        $t->data['stateparams'] = ['AuthState' => $authStateId];
+        $t->data['AuthState'] = $authStateId;
         $t->data['username'] = $username;
         $t->data['forceUsername'] = false;
         $t->data['rememberUsernameEnabled'] = $source->getRememberUsernameEnabled();
diff --git a/modules/core/templates/loginuserpass.twig b/modules/core/templates/loginuserpass.twig
index ded4fec7fa9d811d1845b3426607b4cc0d4cf076..d485d7d01f4bc85393a706793541dfd41d04897b 100644
--- a/modules/core/templates/loginuserpass.twig
+++ b/modules/core/templates/loginuserpass.twig
@@ -38,7 +38,7 @@
     <p>{{ 'A service has requested you to authenticate yourself. Please enter your username and password in the form below.'|trans }}</p>
     <br>
     <div class="center">
-        <form class="pure-form pure-form-aligned center-form" action="?" method="post" name="f">
+        <form class="pure-form pure-form-aligned center-form" action="{{ '?AuthState' ~ AuthState }}" method="post" name="f">
             <div class="form-align">
 
                 <div class="pure-control-group">
@@ -104,10 +104,6 @@
 
             </div> <!-- form-align-->
             <br><br>
-            {%- for name, value in stateparams %}
-
-            <input type="hidden" name="{{ name }}" value="{{ value }}">
-            {%- endfor %}
 
             <button class="pure-button pure-button-red pure-input-1-2 pure-input-sm-1-1 right" id="submit_button"
                     type="submit" tabindex="6" data-processing="{% trans %}Processing...{% endtrans %}">
diff --git a/tests/lib/SimpleSAML/XHTML/TemplateTranslationTest.php b/tests/lib/SimpleSAML/XHTML/TemplateTranslationTest.php
index 3a5c6bf57efff36b6a4597f572f705bef1322ad1..07089206fd36cd9006efb3db77d93ff40376f1fe 100644
--- a/tests/lib/SimpleSAML/XHTML/TemplateTranslationTest.php
+++ b/tests/lib/SimpleSAML/XHTML/TemplateTranslationTest.php
@@ -55,7 +55,7 @@ class TemplateTranslationTest extends TestCase
         $t->data['username'] = 'h.c oersted';
         $t->data['rememberUsernameEnabled'] = false;
         $t->data['rememberMeEnabled'] = false;
-        $t->data['stateparams'] = [];
+        $t->data['AuthState'] = 'abc123';
 
         $getContent = function (): string {
             /** @var \SimpleSAML\XHTML\Template $this */
diff --git a/tests/modules/core/lib/Controller/LoginTest.php b/tests/modules/core/lib/Controller/LoginTest.php
index df10444a76edc749fb27f4c827364cc30a9bb30d..cc16fd7767e95aa44ec0e850b748108ebc164ce9 100644
--- a/tests/modules/core/lib/Controller/LoginTest.php
+++ b/tests/modules/core/lib/Controller/LoginTest.php
@@ -272,7 +272,7 @@ class LoginTest extends ClearStateTestCase
         $response = $c->loginuserpassorg($request);
 
         $this->assertInstanceOf(Template::class, $response);
-        $this->assertEquals('core:loginuserpassorg.twig', $response->getTemplateName());
+        $this->assertEquals('core:loginuserpass.twig', $response->getTemplateName());
     }
      */
 >>>>>>> 051532a60 (Add some unit tests)