mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
errors: Use shared class for message when email is already in use.
Replaces "Email '{email}' already in use" with "Email is already in use."
This commit is contained in:
@@ -756,3 +756,13 @@ class CannotManageDefaultChannelError(JsonableError):
|
||||
@override
|
||||
def msg_format() -> str:
|
||||
return _("You do not have permission to change default channels.")
|
||||
|
||||
|
||||
class EmailAlreadyInUseError(JsonableError):
|
||||
def __init__(self) -> None:
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
@override
|
||||
def msg_format() -> str:
|
||||
return _("Email is already in use.")
|
||||
|
@@ -9433,7 +9433,7 @@ paths:
|
||||
- example:
|
||||
{
|
||||
"code": "BAD_REQUEST",
|
||||
"msg": "Email 'newbie@zulip.com' already in use",
|
||||
"msg": "Email is already in use.",
|
||||
"result": "error",
|
||||
}
|
||||
description: |
|
||||
|
@@ -251,7 +251,7 @@ class BotTest(ZulipTestCase, UploadSerializeMixin):
|
||||
short_name="hambot",
|
||||
)
|
||||
result = self.client_post("/json/bots", bot_info)
|
||||
self.assert_json_error(result, "Email 'hambot-bot@zulip.testserver' already in use")
|
||||
self.assert_json_error(result, "Email is already in use.")
|
||||
|
||||
dup_full_name = "The Bot of Hamlet"
|
||||
|
||||
|
@@ -214,7 +214,7 @@ class TestFullStack(ZulipTestCase):
|
||||
|
||||
# Verify error handling when the user already exists.
|
||||
result = self.client_post("/json/users", valid_params)
|
||||
self.assert_json_error(result, "Email 'romeo@zulip.net' already in use", 400)
|
||||
self.assert_json_error(result, "Email is already in use.", 400)
|
||||
|
||||
def test_tornado_redirects(self) -> None:
|
||||
# Let's poke a bit at Zulip's event system.
|
||||
|
@@ -1336,7 +1336,7 @@ class AdminCreateUserTest(ZulipTestCase):
|
||||
|
||||
# we can't create the same user twice.
|
||||
result = self.client_post("/json/users", valid_params)
|
||||
self.assert_json_error(result, "Email 'romeo@zulip.net' already in use")
|
||||
self.assert_json_error(result, "Email is already in use.")
|
||||
|
||||
# Don't allow user to sign up with disposable email.
|
||||
realm.emails_restricted_to_domains = False
|
||||
|
@@ -45,6 +45,7 @@ from zerver.lib.bot_config import set_bot_config
|
||||
from zerver.lib.email_validation import email_allowed_for_realm, validate_email_not_already_in_realm
|
||||
from zerver.lib.exceptions import (
|
||||
CannotDeactivateLastUserError,
|
||||
EmailAlreadyInUseError,
|
||||
JsonableError,
|
||||
MissingAuthenticationError,
|
||||
OrganizationAdministratorRequiredError,
|
||||
@@ -603,7 +604,7 @@ def add_bot_backend(
|
||||
raise JsonableError(_("Bad name or username"))
|
||||
try:
|
||||
get_user_by_delivery_email(email, user_profile.realm)
|
||||
raise JsonableError(_("Email '{email}' already in use").format(email=email))
|
||||
raise EmailAlreadyInUseError
|
||||
except UserProfile.DoesNotExist:
|
||||
pass
|
||||
|
||||
@@ -810,7 +811,7 @@ def create_user_backend(
|
||||
|
||||
try:
|
||||
get_user_by_delivery_email(email, user_profile.realm)
|
||||
raise JsonableError(_("Email '{email}' already in use").format(email=email))
|
||||
raise EmailAlreadyInUseError
|
||||
except UserProfile.DoesNotExist:
|
||||
pass
|
||||
|
||||
|
Reference in New Issue
Block a user