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 jinja2 import Markup as mark_safe
|
||||||
|
|
||||||
from zerver.lib.actions import do_change_password, email_not_system_bot, \
|
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.name_restrictions import is_reserved_subdomain, is_disposable_domain
|
||||||
from zerver.lib.rate_limiter import RateLimited, get_rate_limit_result_from_request, \
|
from zerver.lib.rate_limiter import RateLimited, get_rate_limit_result_from_request, \
|
||||||
RateLimitedObject, rate_limit_entity
|
RateLimitedObject, rate_limit_entity
|
||||||
|
@ -177,7 +177,7 @@ class HomepageForm(forms.Form):
|
||||||
except EmailContainsPlusError:
|
except EmailContainsPlusError:
|
||||||
raise ValidationError(_("Email addresses containing + are not allowed in this organization."))
|
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:
|
if realm.is_zephyr_mirror_realm:
|
||||||
email_is_not_mit_mailing_list(email)
|
email_is_not_mit_mailing_list(email)
|
||||||
|
|
|
@ -5035,7 +5035,7 @@ def email_not_system_bot(email: str) -> None:
|
||||||
params=dict(deactivated=False),
|
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)
|
email_not_system_bot(email)
|
||||||
|
|
||||||
try:
|
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
|
return _("Email addresses containing + are not allowed."), None, False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
validate_email_for_realm(user_profile.realm, email)
|
validate_email_not_already_in_realm(user_profile.realm, email)
|
||||||
except ValidationError as error:
|
except ValidationError as error:
|
||||||
return None, (error.code), (error.params['deactivated'])
|
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.send_email import send_email, FromAddress
|
||||||
from zerver.lib.actions import do_change_password, do_change_full_name, \
|
from zerver.lib.actions import do_change_password, do_change_full_name, \
|
||||||
do_activate_user, do_create_user, do_create_realm, \
|
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
|
do_set_user_display_setting, lookup_default_stream_groups, bulk_add_subscriptions
|
||||||
from zerver.forms import RegistrationForm, HomepageForm, RealmCreationForm, \
|
from zerver.forms import RegistrationForm, HomepageForm, RealmCreationForm, \
|
||||||
FindMyTeamForm, RealmRedirectForm
|
FindMyTeamForm, RealmRedirectForm
|
||||||
|
@ -110,7 +110,7 @@ def accounts_register(request: HttpRequest) -> HttpResponse:
|
||||||
return redirect_to_deactivation_notice()
|
return redirect_to_deactivation_notice()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
validate_email_for_realm(realm, email)
|
validate_email_not_already_in_realm(realm, email)
|
||||||
except ValidationError:
|
except ValidationError:
|
||||||
return HttpResponseRedirect(reverse('django.contrib.auth.views.login') + '?email=' +
|
return HttpResponseRedirect(reverse('django.contrib.auth.views.login') + '?email=' +
|
||||||
urllib.parse.quote_plus(email))
|
urllib.parse.quote_plus(email))
|
||||||
|
@ -508,7 +508,7 @@ def accounts_home(request: HttpRequest, multiuse_object_key: Optional[str]="",
|
||||||
|
|
||||||
email = request.POST['email']
|
email = request.POST['email']
|
||||||
try:
|
try:
|
||||||
validate_email_for_realm(realm, email)
|
validate_email_not_already_in_realm(realm, email)
|
||||||
except ValidationError:
|
except ValidationError:
|
||||||
return redirect_to_email_login_url(email)
|
return redirect_to_email_login_url(email)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -50,7 +50,7 @@ from social_core.exceptions import AuthFailed, SocialAuthBaseException
|
||||||
|
|
||||||
from zerver.decorator import client_is_exempt_from_rate_limiting
|
from zerver.decorator import client_is_exempt_from_rate_limiting
|
||||||
from zerver.lib.actions import do_create_user, do_reactivate_user, do_deactivate_user, \
|
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 import is_avatar_new, avatar_url
|
||||||
from zerver.lib.avatar_hash import user_avatar_content_hash
|
from zerver.lib.avatar_hash import user_avatar_content_hash
|
||||||
from zerver.lib.dev_ldap_directory import init_fakeldap
|
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
|
# Makes sure that email domain hasn't be restricted for this
|
||||||
# realm. The main thing here is email_allowed_for_realm; but
|
# 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.
|
# even though its checks were already done above.
|
||||||
try:
|
try:
|
||||||
email_allowed_for_realm(username, self._realm)
|
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:
|
except DomainNotAllowedForRealmError:
|
||||||
raise ZulipLDAPException("This email domain isn't allowed in this organization.")
|
raise ZulipLDAPException("This email domain isn't allowed in this organization.")
|
||||||
except (DisposableEmailError, EmailContainsPlusError):
|
except (DisposableEmailError, EmailContainsPlusError):
|
||||||
|
|
Loading…
Reference in New Issue