mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-01-30 20:56:39 +00:00
fix: check none type in _check_response_type_and_not_empty
This commit is contained in:
parent
c5ae43aab3
commit
3bff37cb79
|
@ -158,8 +158,8 @@ def update_user(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_user_by_username(username: str) -> Optional[UserDataUser]:
|
def get_user_by_username(username: str) -> UserDataUser:
|
||||||
user: UserDataUser | None = ACTIVE_USERS_PROVIDER.get_user_by_username(
|
user = ACTIVE_USERS_PROVIDER.get_user_by_username(
|
||||||
username=username
|
username=username
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ from selfprivacy_api.graphql.common_types.user import (
|
||||||
get_users,
|
get_users,
|
||||||
)
|
)
|
||||||
from selfprivacy_api.graphql import IsAuthenticated
|
from selfprivacy_api.graphql import IsAuthenticated
|
||||||
|
# from selfprivacy_api.repositories.users.exceptions import UserNotFound
|
||||||
|
|
||||||
|
|
||||||
@strawberry.type
|
@strawberry.type
|
||||||
|
@ -17,7 +18,11 @@ class Users:
|
||||||
@strawberry.field(permission_classes=[IsAuthenticated])
|
@strawberry.field(permission_classes=[IsAuthenticated])
|
||||||
def get_user(self, username: str) -> typing.Optional[User]:
|
def get_user(self, username: str) -> typing.Optional[User]:
|
||||||
"""Get users"""
|
"""Get users"""
|
||||||
|
|
||||||
|
# try:
|
||||||
return get_user_by_username(username)
|
return get_user_by_username(username)
|
||||||
|
# except UserNotFound:
|
||||||
|
# return None
|
||||||
|
|
||||||
all_users: typing.List[User] = strawberry.field(
|
all_users: typing.List[User] = strawberry.field(
|
||||||
permission_classes=[IsAuthenticated], resolver=get_users
|
permission_classes=[IsAuthenticated], resolver=get_users
|
||||||
|
|
|
@ -118,11 +118,12 @@ class KanidmUserRepository(AbstractUserRepository):
|
||||||
|
|
||||||
logging.info(response_data)
|
logging.info(response_data)
|
||||||
|
|
||||||
|
if response_data is None:
|
||||||
|
raise KanidmReturnEmptyResponse
|
||||||
|
|
||||||
if data_type == "list":
|
if data_type == "list":
|
||||||
if not isinstance(response_data, list):
|
if not isinstance(response_data, list):
|
||||||
raise KanidmReturnUnknownResponseType(response_data=response_data)
|
raise KanidmReturnUnknownResponseType(response_data=response_data)
|
||||||
if not response_data:
|
|
||||||
raise KanidmReturnEmptyResponse
|
|
||||||
|
|
||||||
elif data_type == "dict":
|
elif data_type == "dict":
|
||||||
if not isinstance(response_data, dict):
|
if not isinstance(response_data, dict):
|
||||||
|
|
Loading…
Reference in a new issue