mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 17:07:07 +00:00
Use standard functions for parsing/validating email addresses.
This adds two new functions for parsing out the domain and username
from an email address, and switches our backend to use them and
django.core.validators.valid_email() rather than custom parsing and
raw email.split("@").
(imported from commit 3d6e997d66908811eccb5f82f2f7fe349b40f238)
This commit is contained in:
@@ -8,7 +8,7 @@ from django.core.exceptions import ValidationError
|
||||
from django.db.utils import IntegrityError
|
||||
from django.core import validators
|
||||
|
||||
from zephyr.models import Realm
|
||||
from zephyr.models import Realm, email_to_username
|
||||
from zephyr.lib.actions import do_create_user
|
||||
from zephyr.views import notify_new_user
|
||||
from zephyr.lib.initial_password import initial_password
|
||||
@@ -67,7 +67,7 @@ parameters, or specify no parameters for interactive user creation.""")
|
||||
|
||||
try:
|
||||
notify_new_user(do_create_user(email, initial_password(email),
|
||||
realm, full_name, email.split('@')[0]),
|
||||
realm, full_name, email_to_username(email)),
|
||||
internal=True)
|
||||
except IntegrityError:
|
||||
raise CommandError("User already exists.")
|
||||
|
||||
Reference in New Issue
Block a user