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

@@ -2,7 +2,7 @@ from __future__ import absolute_import
from zephyr.lib.initial_password import initial_password
from zephyr.models import Realm, Stream, UserProfile, Huddle, \
Subscription, Recipient, Client, get_huddle_hash
Subscription, Recipient, Client, get_huddle_hash, email_to_domain
from zephyr.lib.create_user import create_user_profile
def bulk_create_realms(realm_list):
@@ -31,7 +31,7 @@ def bulk_create_users(realms, users_raw):
# Now create user_profiles
profiles_to_create = []
for (email, full_name, short_name, active) in users:
domain = email.split('@')[1]
domain = email_to_domain(email)
profile = create_user_profile(realms[domain], email,
initial_password(email), active, False,
full_name, short_name, None)