From dcb65fdbe0bdadb6dd72c2726ffbe1d6a3af841e Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Fri, 1 Nov 2024 15:43:27 +0100 Subject: [PATCH] refactor: a bit less code --- ldapauthenticator/ldapauthenticator.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ldapauthenticator/ldapauthenticator.py b/ldapauthenticator/ldapauthenticator.py index b752dc7..80a66d3 100644 --- a/ldapauthenticator/ldapauthenticator.py +++ b/ldapauthenticator/ldapauthenticator.py @@ -542,7 +542,6 @@ def get_connection(self, userdn, password): return conn def get_user_attributes(self, conn, userdn): - attrs = {} if self.auth_state_attributes: conn.search( search_base=userdn, @@ -554,13 +553,13 @@ def get_user_attributes(self, conn, userdn): # identify unique search response entry n_entries = len(conn.entries) if n_entries == 1: - attrs = conn.entries[0].entry_attributes_as_dict + return conn.entries[0].entry_attributes_as_dict else: self.log.warning( f"Expected 1 but got {n_entries} search response entries for DN '{userdn}' " f"when looking up attributes configured via auth_state_attributes." ) - return attrs + return {} async def authenticate(self, handler, data): """