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:
Tim Abbott
2013-07-18 12:48:56 -04:00
parent bece588897
commit 18f94de07f
7 changed files with 42 additions and 24 deletions

View File

@@ -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.")