diff --git a/login.php b/login.php
index 512465c0e6bd925785ff3c5ed56296846e4876c4..c944d07c96e205a01845bd5c27a1e0a5fe98512b 100644
--- a/login.php
+++ b/login.php
@@ -48,7 +48,7 @@ if ($_POST) {
 if ($_POST && isset($_POST['luser'])) {
     if (!$_POST['luser'])
         $errors['err'] = __('Valid username or email address is required');
-    elseif (($user = UserAuthenticationBackend::process($_POST['luser'],
+    elseif (($user = UserAuthenticationBackend::process(trim($_POST['luser']),
             $_POST['lpasswd'], $errors))) {
         if ($user instanceof ClientCreateRequest) {
             if ($cfg && $cfg->isClientRegistrationEnabled()) {