ldap: prevent crash when recording a timeout failure (#73342)
gitea/authentic/pipeline/head This commit looks good Details

This commit is contained in:
Benjamin Dauvergne 2023-03-05 15:50:37 +01:00
parent de60d04f36
commit 6786b40583
1 changed files with 2 additions and 2 deletions

View File

@ -1563,11 +1563,11 @@ class LDAPBackend:
attributes = attributes or self.get_ldap_attributes(block, conn, user_id)
ou = self._get_target_ou(block)
for lookup_type in block['lookups']:
if lookup_type == 'external_id':
if lookup_type == 'external_id' and attributes:
user = self._lookup_by_external_id(block=block, attributes=attributes)
elif lookup_type == 'username':
user = self._lookup_by_username(ou=ou, block=block, username=user_id)
elif lookup_type == 'email':
elif lookup_type == 'email' and attributes:
user = self._lookup_by_email(ou=ou, block=block, attributes=attributes)
if user:
break