auth: Separate email_auth_enabled from ldap_auth_enabled.

This commit is contained in:
Tim Abbott 2016-11-06 15:04:59 -08:00
parent f8bb55f9c1
commit 30ab27c843
1 changed files with 13 additions and 1 deletions

View File

@ -45,9 +45,17 @@ def auth_enabled_helper(backends_to_check, realm):
return True
return False
def ldap_auth_enabled(realm=None):
# type: (Optional[Realm]) -> bool
return auth_enabled_helper([u'LDAP'], realm)
def email_auth_enabled(realm=None):
# type: (Optional[Realm]) -> bool
return auth_enabled_helper([u'Email'], realm)
def password_auth_enabled(realm=None):
# type: (Optional[Realm]) -> bool
return auth_enabled_helper([u'Email', u'LDAP'], realm)
return ldap_auth_enabled(realm) or email_auth_enabled(realm)
def dev_auth_enabled(realm=None):
# type: (Optional[Realm]) -> bool
@ -187,6 +195,10 @@ class EmailAuthBackend(ZulipAuthMixin):
if return_data is not None:
return_data['password_auth_disabled'] = True
return None
if not email_auth_enabled(user_profile.realm):
if return_data is not None:
return_data['email_auth_disabled'] = True
return None
if user_profile.check_password(password):
if not check_subdomain(realm_subdomain, user_profile.realm.subdomain):
return_data["invalid_subdomain"] = True