mirror of https://github.com/zulip/zulip.git
refactor: Rename validate_email_for_realm.
Now called: validate_email_not_already_in_realm We have a separate validation function that makes sure that the email fits into a realm's domain scheme, and we want to avoid naming confusion here.
This commit is contained in:
parent
c43a29ff54
commit
57f1aa722c
|
@ -15,7 +15,7 @@ from django.http import HttpRequest
|
|||
from jinja2 import Markup as mark_safe
|
||||
|
||||
from zerver.lib.actions import do_change_password, email_not_system_bot, \
|
||||
validate_email_for_realm
|
||||
validate_email_not_already_in_realm
|
||||
from zerver.lib.name_restrictions import is_reserved_subdomain, is_disposable_domain
|
||||
from zerver.lib.rate_limiter import RateLimited, get_rate_limit_result_from_request, \
|
||||
RateLimitedObject, rate_limit_entity
|
||||
|
@ -177,7 +177,7 @@ class HomepageForm(forms.Form):
|
|||
except EmailContainsPlusError:
|
||||
raise ValidationError(_("Email addresses containing + are not allowed in this organization."))
|
||||
|
||||
validate_email_for_realm(realm, email)
|
||||
validate_email_not_already_in_realm(realm, email)
|
||||
|
||||
if realm.is_zephyr_mirror_realm:
|
||||
email_is_not_mit_mailing_list(email)
|
||||
|
|
|
@ -5035,7 +5035,7 @@ def email_not_system_bot(email: str) -> None:
|
|||
params=dict(deactivated=False),
|
||||
)
|
||||
|
||||
def validate_email_for_realm(target_realm: Realm, email: str) -> None:
|
||||
def validate_email_not_already_in_realm(target_realm: Realm, email: str) -> None:
|
||||
email_not_system_bot(email)
|
||||
|
||||
try:
|
||||
|
@ -5070,7 +5070,7 @@ def validate_email(user_profile: UserProfile, email: str) -> Tuple[Optional[str]
|
|||
return _("Email addresses containing + are not allowed."), None, False
|
||||
|
||||
try:
|
||||
validate_email_for_realm(user_profile.realm, email)
|
||||
validate_email_not_already_in_realm(user_profile.realm, email)
|
||||
except ValidationError as error:
|
||||
return None, (error.code), (error.params['deactivated'])
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ from zerver.models import UserProfile, Realm, Stream, MultiuseInvite, \
|
|||
from zerver.lib.send_email import send_email, FromAddress
|
||||
from zerver.lib.actions import do_change_password, do_change_full_name, \
|
||||
do_activate_user, do_create_user, do_create_realm, \
|
||||
validate_email_for_realm, \
|
||||
validate_email_not_already_in_realm, \
|
||||
do_set_user_display_setting, lookup_default_stream_groups, bulk_add_subscriptions
|
||||
from zerver.forms import RegistrationForm, HomepageForm, RealmCreationForm, \
|
||||
FindMyTeamForm, RealmRedirectForm
|
||||
|
@ -110,7 +110,7 @@ def accounts_register(request: HttpRequest) -> HttpResponse:
|
|||
return redirect_to_deactivation_notice()
|
||||
|
||||
try:
|
||||
validate_email_for_realm(realm, email)
|
||||
validate_email_not_already_in_realm(realm, email)
|
||||
except ValidationError:
|
||||
return HttpResponseRedirect(reverse('django.contrib.auth.views.login') + '?email=' +
|
||||
urllib.parse.quote_plus(email))
|
||||
|
@ -508,7 +508,7 @@ def accounts_home(request: HttpRequest, multiuse_object_key: Optional[str]="",
|
|||
|
||||
email = request.POST['email']
|
||||
try:
|
||||
validate_email_for_realm(realm, email)
|
||||
validate_email_not_already_in_realm(realm, email)
|
||||
except ValidationError:
|
||||
return redirect_to_email_login_url(email)
|
||||
else:
|
||||
|
|
|
@ -50,7 +50,7 @@ from social_core.exceptions import AuthFailed, SocialAuthBaseException
|
|||
|
||||
from zerver.decorator import client_is_exempt_from_rate_limiting
|
||||
from zerver.lib.actions import do_create_user, do_reactivate_user, do_deactivate_user, \
|
||||
do_update_user_custom_profile_data_if_changed, validate_email_for_realm
|
||||
do_update_user_custom_profile_data_if_changed, validate_email_not_already_in_realm
|
||||
from zerver.lib.avatar import is_avatar_new, avatar_url
|
||||
from zerver.lib.avatar_hash import user_avatar_content_hash
|
||||
from zerver.lib.dev_ldap_directory import init_fakeldap
|
||||
|
@ -674,11 +674,11 @@ class ZulipLDAPAuthBackend(ZulipLDAPAuthBackendBase):
|
|||
|
||||
# Makes sure that email domain hasn't be restricted for this
|
||||
# realm. The main thing here is email_allowed_for_realm; but
|
||||
# we also call validate_email_for_realm just for consistency,
|
||||
# we also call validate_email_not_already_in_realm just for consistency,
|
||||
# even though its checks were already done above.
|
||||
try:
|
||||
email_allowed_for_realm(username, self._realm)
|
||||
validate_email_for_realm(self._realm, username)
|
||||
validate_email_not_already_in_realm(self._realm, username)
|
||||
except DomainNotAllowedForRealmError:
|
||||
raise ZulipLDAPException("This email domain isn't allowed in this organization.")
|
||||
except (DisposableEmailError, EmailContainsPlusError):
|
||||
|
|
Loading…
Reference in New Issue