When inviting users, check if the invitee is in-domain or the realm is open.

(imported from commit 42e072d9717f38cc6d0c7010d37bbabd81aa3ae7)
This commit is contained in:
Jessica McKellar 2013-02-05 16:59:21 -05:00
parent aeba3beb55
commit a332bee2b7
1 changed files with 4 additions and 4 deletions

View File

@ -324,13 +324,13 @@ def json_invite_users(request, user_profile, invitee_emails=POST):
for email in invitee_emails:
if email == '':
continue
try:
validators.validate_email(email)
except ValidationError:
if not validators.email_re.match(email):
errors.append((email, "Invalid address."))
continue
if email.split('@')[-1] != user_profile.realm.domain:
if user_profile.realm.restricted_to_domain and \
email.split('@', 1)[-1] != user_profile.realm.domain:
errors.append((email, "Outside your domain."))
continue