mirror of https://github.com/zulip/zulip.git
actions: Move part into zerver.forms.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
eda000899b
commit
12de8d797e
|
@ -21,8 +21,10 @@ from two_factor.utils import totp_digits
|
|||
|
||||
from zerver.actions.user_settings import do_change_password
|
||||
from zerver.decorator import rate_limit_request_by_ip
|
||||
from zerver.lib.actions import email_not_system_bot
|
||||
from zerver.lib.email_validation import email_allowed_for_realm
|
||||
from zerver.lib.email_validation import (
|
||||
email_allowed_for_realm,
|
||||
email_reserved_for_system_bots_error,
|
||||
)
|
||||
from zerver.lib.exceptions import JsonableError, RateLimited
|
||||
from zerver.lib.name_restrictions import is_disposable_domain, is_reserved_subdomain
|
||||
from zerver.lib.rate_limiter import RateLimitedObject
|
||||
|
@ -38,6 +40,7 @@ from zerver.models import (
|
|||
email_to_domain,
|
||||
get_realm,
|
||||
get_user_by_delivery_email,
|
||||
is_cross_realm_bot_email,
|
||||
)
|
||||
from zproject.backends import check_password_strength, email_auth_enabled, email_belongs_to_ldap
|
||||
|
||||
|
@ -223,6 +226,17 @@ class HomepageForm(forms.Form):
|
|||
return email
|
||||
|
||||
|
||||
def email_not_system_bot(email: str) -> None:
|
||||
if is_cross_realm_bot_email(email):
|
||||
msg = email_reserved_for_system_bots_error(email)
|
||||
code = msg
|
||||
raise ValidationError(
|
||||
msg,
|
||||
code=code,
|
||||
params=dict(deactivated=False),
|
||||
)
|
||||
|
||||
|
||||
def email_is_not_disposable(email: str) -> None:
|
||||
if is_disposable_domain(email_to_domain(email)):
|
||||
raise ValidationError(_("Please use your real email address."))
|
||||
|
|
|
@ -4,7 +4,6 @@ from typing import Any, Dict, List, Optional, Sequence
|
|||
|
||||
import orjson
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.db import transaction
|
||||
from django.utils.timezone import now as timezone_now
|
||||
from django.utils.translation import gettext as _
|
||||
|
@ -18,7 +17,6 @@ from zerver.actions.user_settings import do_delete_avatar_image, send_user_email
|
|||
from zerver.lib.bulk_create import create_users
|
||||
from zerver.lib.cache import flush_user_profile
|
||||
from zerver.lib.create_user import get_display_email_address
|
||||
from zerver.lib.email_validation import email_reserved_for_system_bots_error
|
||||
from zerver.lib.message import update_first_visible_message_id
|
||||
from zerver.lib.send_email import FromAddress, send_email_to_admins
|
||||
from zerver.lib.server_initialization import create_internal_realm, server_initialized
|
||||
|
@ -43,7 +41,6 @@ from zerver.models import (
|
|||
get_realm,
|
||||
get_realm_domains,
|
||||
get_system_bot,
|
||||
is_cross_realm_bot_email,
|
||||
)
|
||||
from zerver.tornado.django_api import send_event
|
||||
|
||||
|
@ -680,17 +677,6 @@ def do_create_realm(
|
|||
return realm
|
||||
|
||||
|
||||
def email_not_system_bot(email: str) -> None:
|
||||
if is_cross_realm_bot_email(email):
|
||||
msg = email_reserved_for_system_bots_error(email)
|
||||
code = msg
|
||||
raise ValidationError(
|
||||
msg,
|
||||
code=code,
|
||||
params=dict(deactivated=False),
|
||||
)
|
||||
|
||||
|
||||
@transaction.atomic(durable=True)
|
||||
def do_add_realm_domain(
|
||||
realm: Realm, domain: str, allow_subdomains: bool, *, acting_user: Optional[UserProfile]
|
||||
|
|
Loading…
Reference in New Issue