mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
actions: Move part into zerver.forms.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit 12de8d797e)
This commit is contained in:
committed by
Tim Abbott
parent
eb5832f7a4
commit
87c58f8e23
@@ -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."))
|
||||
|
||||
Reference in New Issue
Block a user