fix: kanidm errors comparison

This commit is contained in:
dettlaff 2024-12-10 22:06:47 +04:00
parent d4dada174a
commit 3bf4cafb0a

View file

@ -155,9 +155,11 @@ class KanidmUserRepository(AbstractUserRepository):
response = response.json() response = response.json()
if response["plugin"]: if response and response != []:
if response["plugin"].get("attrunique") == "duplicate value detected": if response[0]["plugin"].get("attrunique") == "duplicate value detected":
raise UserAlreadyExists # TODO only user? raise UserAlreadyExists # TODO only user?
else:
raise KanidmReturnEmptyResponse
return response return response
@ -217,9 +219,6 @@ class KanidmUserRepository(AbstractUserRepository):
""" """
users_data = KanidmUserRepository._send_query(endpoint="person", method="GET") users_data = KanidmUserRepository._send_query(endpoint="person", method="GET")
if not users_data:
raise KanidmReturnEmptyResponse
users = [] users = []
for user in users_data: for user in users_data:
user_attrs = user.get("attrs", {}) user_attrs = user.get("attrs", {})
@ -291,9 +290,6 @@ class KanidmUserRepository(AbstractUserRepository):
method="GET", method="GET",
) )
if not user_data or "attrs" not in user_data:
raise KanidmReturnEmptyResponse
attrs = user_data["attrs"] attrs = user_data["attrs"]
return UserDataUser( return UserDataUser(
@ -319,9 +315,6 @@ class KanidmUserRepository(AbstractUserRepository):
method="GET", method="GET",
) )
if not data:
raise KanidmReturnEmptyResponse
token = data.get("token", None) token = data.get("token", None)
if not token: if not token: