mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	ldap: Add return_data for the ldap_missing_attribute property.
This should make it possible in the future to do better error output for this case.
This commit is contained in:
		@@ -444,16 +444,17 @@ class ZulipLDAPAuthBackend(ZulipLDAPAuthBackendBase):
 | 
			
		||||
                                                     password=password)
 | 
			
		||||
 | 
			
		||||
    def get_or_build_user(self, username: str, ldap_user: _LDAPUser) -> Tuple[UserProfile, bool]:
 | 
			
		||||
        return_data = {}  # type: Dict[str, Any]
 | 
			
		||||
 | 
			
		||||
        if settings.LDAP_EMAIL_ATTR is not None:
 | 
			
		||||
            # Get email from ldap attributes.
 | 
			
		||||
            if settings.LDAP_EMAIL_ATTR not in ldap_user.attrs:
 | 
			
		||||
                return_data["ldap_missing_attribute"] = settings.LDAP_EMAIL_ATTR
 | 
			
		||||
                raise ZulipLDAPException("LDAP user doesn't have the needed %s attribute" % (
 | 
			
		||||
                    settings.LDAP_EMAIL_ATTR,))
 | 
			
		||||
 | 
			
		||||
            username = ldap_user.attrs[settings.LDAP_EMAIL_ATTR][0]
 | 
			
		||||
 | 
			
		||||
        return_data = {}  # type: Dict[str, Any]
 | 
			
		||||
        user_profile = common_get_active_user(username, self._realm, return_data)
 | 
			
		||||
        if user_profile is not None:
 | 
			
		||||
            # An existing user, successfully authed; return it.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user