From 870af19ba4c14a38977905d3d1e3569159998b16 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Wed, 17 Jan 2024 11:48:18 +0530 Subject: [PATCH] Update health API to pass authenticated users their info This allows Khoj clients to get email address associated with user's API token for display in client UX In anonymous mode, default user information is passed --- src/khoj/routers/api.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/khoj/routers/api.py b/src/khoj/routers/api.py index a6748d4f..01d939ae 100644 --- a/src/khoj/routers/api.py +++ b/src/khoj/routers/api.py @@ -554,6 +554,8 @@ async def extract_references_and_questions( return compiled_references, inferred_queries, defiltered_query -@api.get("/health") -async def health_check(): - return Response(status_code=200) +@api.get("/health", response_class=Response) +@requires(["authenticated"], status_code=200) +def health_check(request: Request) -> Response: + response_obj = {"email": request.user.object.email} + return Response(content=json.dumps(response_obj), media_type="application/json", status_code=200)