From dacb97765574fd899102917755cb5e9eb43ab4d7 Mon Sep 17 00:00:00 2001 From: Adrien Faure Date: Wed, 22 Nov 2023 14:44:59 +0100 Subject: [PATCH] [oar/api/frontend] fix whoami crashes --- oar/api/routers/frontend.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/oar/api/routers/frontend.py b/oar/api/routers/frontend.py index 23ee1796..f1c349c0 100644 --- a/oar/api/routers/frontend.py +++ b/oar/api/routers/frontend.py @@ -49,12 +49,17 @@ def version(): @router.get("/whoami") -def whoami(user: str = Depends(get_token_data)): +def whoami(data: str = Depends(get_token_data)): """Give the name of the authenticated user seen by OAR API. The name for a not authenticated user is the null string. """ - return {"authenticated_user": user["user"]} + user = "" + + if data: + user = data["user"] + + return {"authenticated_user": user} @router.get("/check_token")