mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 21:13:36 +00:00
ldap: Shrink unnecessary scope of missing user block.
This is a pure refactor, and will help simplify the change in the next commit.
This commit is contained in:
@@ -465,15 +465,16 @@ class ZulipLDAPAuthBackend(ZulipLDAPAuthBackendBase):
|
||||
|
||||
def get_or_create_user(self, username, ldap_user):
|
||||
# type: (str, _LDAPUser) -> Tuple[UserProfile, bool]
|
||||
|
||||
if settings.LDAP_EMAIL_ATTR is not None:
|
||||
# Get email from ldap attributes.
|
||||
if settings.LDAP_EMAIL_ATTR not in ldap_user.attrs:
|
||||
raise ZulipLDAPException("LDAP user doesn't have the needed %s attribute" % (
|
||||
settings.LDAP_EMAIL_ATTR,))
|
||||
|
||||
username = ldap_user.attrs[settings.LDAP_EMAIL_ATTR][0]
|
||||
|
||||
try:
|
||||
if settings.LDAP_EMAIL_ATTR is not None:
|
||||
# Get email from ldap attributes.
|
||||
if settings.LDAP_EMAIL_ATTR not in ldap_user.attrs:
|
||||
raise ZulipLDAPException("LDAP user doesn't have the needed %s attribute" % (
|
||||
settings.LDAP_EMAIL_ATTR,))
|
||||
|
||||
username = ldap_user.attrs[settings.LDAP_EMAIL_ATTR][0]
|
||||
|
||||
user_profile = get_user_profile_by_email(username)
|
||||
if not user_profile.is_active or user_profile.realm.deactivated:
|
||||
raise ZulipLDAPException("Realm has been deactivated")
|
||||
|
||||
Reference in New Issue
Block a user