mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 20:44:04 +00:00
remote_user_sso: Improve invalid email message.
Show a user friendly message to the user if email is invalid. Currently we show a generic message: "Your username or password is incorrect."
This commit is contained in:
@@ -1309,6 +1309,13 @@ class TestZulipRemoteUserBackend(ZulipTestCase):
|
||||
self.assertEqual(result.status_code, 302)
|
||||
self.assertIs(get_session_dict_user(self.client.session), None)
|
||||
|
||||
def test_login_failure_due_to_invalid_email(self):
|
||||
# type: () -> None
|
||||
email = 'hamlet'
|
||||
with self.settings(AUTHENTICATION_BACKENDS=('zproject.backends.ZulipRemoteUserBackend',)):
|
||||
result = self.client_post('/accounts/login/sso/', REMOTE_USER=email)
|
||||
self.assert_json_error_contains(result, "Enter a valid email address.", 400)
|
||||
|
||||
def test_login_failure_due_to_missing_field(self):
|
||||
# type: () -> None
|
||||
with self.settings(AUTHENTICATION_BACKENDS=('zproject.backends.ZulipRemoteUserBackend',)):
|
||||
|
||||
@@ -106,6 +106,12 @@ def remote_user_sso(request):
|
||||
except KeyError:
|
||||
raise JsonableError(_("No REMOTE_USER set."))
|
||||
|
||||
# Django invokes authenticate methods by matching arguments, and this
|
||||
# authentication flow will not invoke LDAP authentication because of
|
||||
# this condition of Django so no need to check if LDAP backend is
|
||||
# enabled.
|
||||
validate_login_email(remote_user_to_email(remote_user))
|
||||
|
||||
user_profile = authenticate(remote_user=remote_user, realm_subdomain=get_subdomain(request))
|
||||
return login_or_register_remote_user(request, remote_user, user_profile)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user