mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
forms.py: Include email in the error messages.
This commit is contained in:
@@ -127,17 +127,24 @@ class HomepageForm(forms.Form):
|
||||
|
||||
if realm is None:
|
||||
if settings.REALMS_HAVE_SUBDOMAINS:
|
||||
raise ValidationError(_("The organization you are trying to join does not exist."))
|
||||
raise ValidationError(_("The organization you are trying to "
|
||||
"join using {email} does not "
|
||||
"exist.").format(email=email))
|
||||
else:
|
||||
raise ValidationError(_("Your email address does not correspond to any existing organization."))
|
||||
raise ValidationError(_("Your email address, {email}, does not "
|
||||
"correspond to any existing "
|
||||
"organization.").format(email=email))
|
||||
|
||||
if realm.invite_required:
|
||||
raise ValidationError(_("Please request an invite from the organization administrator."))
|
||||
raise ValidationError(_("Please request an invite for {email} "
|
||||
"from the organization "
|
||||
"administrator.").format(email=email))
|
||||
|
||||
if not email_allowed_for_realm(email, realm):
|
||||
raise ValidationError(
|
||||
_("The organization you are trying to join, {string_id}, only allows users with e-mail "
|
||||
"addresses within the organization. Please try a different e-mail address.").format(string_id=realm.string_id))
|
||||
_("Your email address, {email}, is not in one of the domains "
|
||||
"that are allowed to register for accounts in this organization."
|
||||
).format(string_id=realm.string_id, email=email))
|
||||
|
||||
if realm.is_zephyr_mirror_realm:
|
||||
email_is_not_mit_mailing_list(email)
|
||||
|
||||
@@ -584,11 +584,13 @@ class GitHubAuthBackendTest(ZulipTestCase):
|
||||
|
||||
with mock.patch('social_core.backends.github.GithubOAuth2.do_auth',
|
||||
side_effect=do_auth):
|
||||
response = dict(email='nonexisting@phantom.com', name='Ghost')
|
||||
email = 'nonexisting@phantom.com'
|
||||
response = dict(email=email, name='Ghost')
|
||||
result = self.backend.do_auth(response=response)
|
||||
self.assert_in_response('action="/register/"', result)
|
||||
self.assert_in_response('Your email address does not correspond to any '
|
||||
'existing organization.', result)
|
||||
self.assert_in_response('Your email address, {}, does not '
|
||||
'correspond to any existing '
|
||||
'organization.'.format(email), result)
|
||||
|
||||
def test_login_url(self):
|
||||
# type: () -> None
|
||||
|
||||
@@ -1239,8 +1239,10 @@ class UserSignUpTest(ZulipTestCase):
|
||||
with self.settings(REALMS_HAVE_SUBDOMAINS = True):
|
||||
request = HostRequestMock(host = realm.host)
|
||||
request.session = {} # type: ignore
|
||||
form = HomepageForm({'email': 'user@acme.com'}, realm=realm)
|
||||
self.assertIn("trying to join, zulip, only allows users with e-mail", form.errors['email'][0])
|
||||
email = 'user@acme.com'
|
||||
form = HomepageForm({'email': email}, realm=realm)
|
||||
self.assertIn("Your email address, {}, is not in one of the domains".format(email),
|
||||
form.errors['email'][0])
|
||||
|
||||
def test_failed_signup_due_to_invite_required(self):
|
||||
# type: () -> None
|
||||
@@ -1249,16 +1251,20 @@ class UserSignUpTest(ZulipTestCase):
|
||||
realm.save()
|
||||
request = HostRequestMock(host = realm.host)
|
||||
request.session = {} # type: ignore
|
||||
form = HomepageForm({'email': 'user@zulip.com'}, realm=realm)
|
||||
self.assertIn("Please request an invite from", form.errors['email'][0])
|
||||
email = 'user@zulip.com'
|
||||
form = HomepageForm({'email': email}, realm=realm)
|
||||
self.assertIn("Please request an invite for {} from".format(email),
|
||||
form.errors['email'][0])
|
||||
|
||||
def test_failed_signup_due_to_nonexistent_realm(self):
|
||||
# type: () -> None
|
||||
with self.settings(REALMS_HAVE_SUBDOMAINS = True):
|
||||
request = HostRequestMock(host = 'acme.' + settings.EXTERNAL_HOST)
|
||||
request.session = {} # type: ignore
|
||||
form = HomepageForm({'email': 'user@acme.com'}, realm=None)
|
||||
self.assertIn("organization you are trying to join does not exist", form.errors['email'][0])
|
||||
email = 'user@acme.com'
|
||||
form = HomepageForm({'email': email}, realm=None)
|
||||
self.assertIn("organization you are trying to join using {} does "
|
||||
"not exist".format(email), form.errors['email'][0])
|
||||
|
||||
def test_registration_through_ldap(self):
|
||||
# type: () -> None
|
||||
|
||||
Reference in New Issue
Block a user