diff --git a/scp/login.php b/scp/login.php
index 0fc0d0991410c3a2a7ee019aab7ee1c91dd9c4ad..0d8b14d429261409786a3bbf1c59c7abbe0960c1 100644
--- a/scp/login.php
+++ b/scp/login.php
@@ -40,7 +40,8 @@ if($_POST) {
 
     // Rotate the CSRF token (original cannot be reused)
     $ost->getCSRF()->rotate();
-
+}
+if ($_POST && isset($_POST['userid'])) {
     // Lookup support backends for this staff
     $username = trim($_POST['userid']);
     if ($user = StaffAuthenticationBackend::process($username,
@@ -66,8 +67,11 @@ elseif ($_GET['do']) {
 // Consider single sign-on authentication backends
 elseif (!$thisstaff || !($thisstaff->getId() || $thisstaff->isValid())) {
     if (($user = StaffAuthenticationBackend::processSignOn($errors, false))
-            && ($user instanceof StaffSession))
-       Http::redirect($dest);
+            && ($user instanceof StaffSession)) {
+        Http::redirect($dest);
+    } else if (isset($_SESSION['_staff']['auth']['msg'])) {
+        $msg = $_SESSION['_staff']['auth']['msg'];
+    }
 }
 
 // Browsers shouldn't suggest saving that username/password