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