auth: Fix invalid credentials message in login form.

Email is not case-sensitive. And password is obviously case-sensitive,
so no point mentioning that.
This commit is contained in:
Mateusz Mandera
2024-10-23 14:02:26 +02:00
committed by Tim Abbott
parent 30ada20ece
commit af9b44ed02
2 changed files with 4 additions and 7 deletions

View File

@@ -52,6 +52,7 @@ MIT_VALIDATION_ERROR = Markup(
' <a href="mailto:support@zulip.com">contact us</a>.' ' <a href="mailto:support@zulip.com">contact us</a>.'
) )
INVALID_ACCOUNT_CREDENTIALS_ERROR = gettext_lazy("Please enter a correct email and password.")
DEACTIVATED_ACCOUNT_ERROR = gettext_lazy( DEACTIVATED_ACCOUNT_ERROR = gettext_lazy(
"Your account {username} has been deactivated." "Your account {username} has been deactivated."
" Please contact your organization administrator to reactivate it." " Please contact your organization administrator to reactivate it."
@@ -514,9 +515,7 @@ class OurAuthenticationForm(AuthenticationForm):
if self.user_cache is None: if self.user_cache is None:
raise forms.ValidationError( raise forms.ValidationError(
self.error_messages["invalid_login"], INVALID_ACCOUNT_CREDENTIALS_ERROR,
code="invalid_login",
params={"username": self.username_field.verbose_name},
) )
self.confirm_login_allowed(self.user_cache) self.confirm_login_allowed(self.user_cache)

View File

@@ -993,7 +993,7 @@ class LoginTest(ZulipTestCase):
def test_login_nonexistent_user(self) -> None: def test_login_nonexistent_user(self) -> None:
result = self.login_with_return("xxx@zulip.com", "xxx") result = self.login_with_return("xxx@zulip.com", "xxx")
self.assertEqual(result.status_code, 200) self.assertEqual(result.status_code, 200)
self.assert_in_response("Please enter a correct email and password", result) self.assert_in_response("Please enter a correct email and password.", result)
self.assert_logged_in_user_id(None) self.assert_logged_in_user_id(None)
def test_login_wrong_subdomain(self) -> None: def test_login_wrong_subdomain(self) -> None:
@@ -1009,9 +1009,7 @@ class LoginTest(ZulipTestCase):
], ],
) )
self.assertEqual(result.status_code, 200) self.assertEqual(result.status_code, 200)
expected_error = ( expected_error = "Please enter a correct email and password."
"Please enter a correct email and password. Note that both fields may be case-sensitive"
)
self.assert_in_response(expected_error, result) self.assert_in_response(expected_error, result)
self.assert_logged_in_user_id(None) self.assert_logged_in_user_id(None)