Fix error handling in WhoAmI data view
This commit is contained in:
parent
c323eabd6f
commit
e1183fff60
@ -36,6 +36,7 @@ from ..utils.auth import (
|
|||||||
from ..utils.autoupdate import AutoupdateElement, inform_changed_data, inform_elements
|
from ..utils.autoupdate import AutoupdateElement, inform_changed_data, inform_elements
|
||||||
from ..utils.cache import element_cache
|
from ..utils.cache import element_cache
|
||||||
from ..utils.rest_api import (
|
from ..utils.rest_api import (
|
||||||
|
APIException,
|
||||||
ModelViewSet,
|
ModelViewSet,
|
||||||
Response,
|
Response,
|
||||||
SimpleMetadata,
|
SimpleMetadata,
|
||||||
@ -858,9 +859,8 @@ class WhoAmIDataView(APIView):
|
|||||||
self.request.user.get_collection_string(), user_id
|
self.request.user.get_collection_string(), user_id
|
||||||
)
|
)
|
||||||
if user_full_data is None:
|
if user_full_data is None:
|
||||||
return Response(
|
raise APIException(f"Could not find user {user_id}", 500)
|
||||||
{"detail": "Cache offline, could not fetch user"}, status=500
|
|
||||||
)
|
|
||||||
auth_type = user_full_data["auth_type"]
|
auth_type = user_full_data["auth_type"]
|
||||||
user_data = async_to_sync(element_cache.restrict_element_data)(
|
user_data = async_to_sync(element_cache.restrict_element_data)(
|
||||||
user_full_data, self.request.user.get_collection_string(), user_id
|
user_full_data, self.request.user.get_collection_string(), user_id
|
||||||
|
@ -51,6 +51,7 @@ from .cache import element_cache
|
|||||||
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
|
"APIException",
|
||||||
"detail_route",
|
"detail_route",
|
||||||
"DecimalField",
|
"DecimalField",
|
||||||
"list_route",
|
"list_route",
|
||||||
|
Loading…
Reference in New Issue
Block a user