models.email_allowed_for_realm: Use RealmAlias instead of domain.

This commit is contained in:
Rishi Gupta 2016-11-08 16:55:45 -08:00 committed by Tim Abbott
parent 70ab79d056
commit 1c869c2287
1 changed files with 2 additions and 5 deletions

View File

@ -315,13 +315,10 @@ def resolve_email_to_domain(email):
# not whether the user can sign up currently.)
def email_allowed_for_realm(email, realm):
# type: (text_type, Realm) -> bool
# Anyone can be in an open realm
if not realm.restricted_to_domain:
return True
# Otherwise, domains must match (case-insensitively)
email_domain = resolve_email_to_domain(email)
return email_domain == realm.domain.lower()
domain = split_email_to_domain(email)
return RealmAlias.objects.filter(realm = realm, domain = domain).exists()
def alias_for_realm(domain):
# type: (text_type) -> Optional[RealmAlias]