diff --git a/selfprivacy_api/actions/users.py b/selfprivacy_api/actions/users.py index 8c60d98..b9eaddd 100644 --- a/selfprivacy_api/actions/users.py +++ b/selfprivacy_api/actions/users.py @@ -158,8 +158,8 @@ def update_user( ) -def get_user_by_username(username: str) -> Optional[UserDataUser]: - user: UserDataUser | None = ACTIVE_USERS_PROVIDER.get_user_by_username( +def get_user_by_username(username: str) -> UserDataUser: + user = ACTIVE_USERS_PROVIDER.get_user_by_username( username=username ) diff --git a/selfprivacy_api/graphql/queries/users.py b/selfprivacy_api/graphql/queries/users.py index 992ce01..42fa60f 100644 --- a/selfprivacy_api/graphql/queries/users.py +++ b/selfprivacy_api/graphql/queries/users.py @@ -10,6 +10,7 @@ from selfprivacy_api.graphql.common_types.user import ( get_users, ) from selfprivacy_api.graphql import IsAuthenticated +# from selfprivacy_api.repositories.users.exceptions import UserNotFound @strawberry.type @@ -17,7 +18,11 @@ class Users: @strawberry.field(permission_classes=[IsAuthenticated]) def get_user(self, username: str) -> typing.Optional[User]: """Get users""" + + # try: return get_user_by_username(username) + # except UserNotFound: + # return None all_users: typing.List[User] = strawberry.field( permission_classes=[IsAuthenticated], resolver=get_users diff --git a/selfprivacy_api/repositories/users/kanidm_user_repository.py b/selfprivacy_api/repositories/users/kanidm_user_repository.py index ce27e7a..3e2d2a4 100644 --- a/selfprivacy_api/repositories/users/kanidm_user_repository.py +++ b/selfprivacy_api/repositories/users/kanidm_user_repository.py @@ -118,11 +118,12 @@ class KanidmUserRepository(AbstractUserRepository): logging.info(response_data) + if response_data is None: + raise KanidmReturnEmptyResponse + if data_type == "list": if not isinstance(response_data, list): raise KanidmReturnUnknownResponseType(response_data=response_data) - if not response_data: - raise KanidmReturnEmptyResponse elif data_type == "dict": if not isinstance(response_data, dict):