mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 18:36:36 +00:00
auth: Remove unnecessary case from validate_email_for_realm.
The removed code path was only needed due to buggy setup code in the test_cross_realm_scenarios test. We address that with a less buggy workaround, and which lets us remove unnecessary complexity from this important validation function. Thanks for Umair Waheed for some preliminary work on this. Fixes #7561.
This commit is contained in:
@@ -4092,16 +4092,7 @@ def email_not_system_bot(email: Text) -> None:
|
||||
raise ValidationError('%s is an email address reserved for system bots' % (email,))
|
||||
|
||||
def validate_email_for_realm(target_realm: Realm, email: Text) -> None:
|
||||
try:
|
||||
# Registering with a system bot's email is not allowed...
|
||||
email_not_system_bot(email)
|
||||
except ValidationError:
|
||||
# ... unless this is the first user with that email. This
|
||||
# should be impossible in production, because these users are
|
||||
# created by initialize_voyager_db, but it happens in a test's
|
||||
# setup. (This would be a good wrinkle to clean up.)
|
||||
if UserProfile.objects.filter(email__iexact=email).exists():
|
||||
raise
|
||||
email_not_system_bot(email)
|
||||
|
||||
try:
|
||||
existing_user_profile = get_user(email, target_realm)
|
||||
|
||||
Reference in New Issue
Block a user