From 1a9cf903fdf0dd476ba527b871a3e478d8f55f01 Mon Sep 17 00:00:00 2001 From: Igor Ilic <30923996+dexters1@users.noreply.github.com> Date: Mon, 2 Jun 2025 22:12:35 +0200 Subject: [PATCH] fix: Resolve issue with UI auth (#900) ## Description ## DCO Affirmation I affirm that all code in every commit of this pull request conforms to the terms of the Topoteretes Developer Certificate of Origin. --- cognee/modules/users/methods/get_authenticated_user.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cognee/modules/users/methods/get_authenticated_user.py b/cognee/modules/users/methods/get_authenticated_user.py index ae7825202..c181369b8 100644 --- a/cognee/modules/users/methods/get_authenticated_user.py +++ b/cognee/modules/users/methods/get_authenticated_user.py @@ -21,7 +21,7 @@ async def get_authenticated_user(authorization: str = Header(...)) -> SimpleName token, os.getenv("FASTAPI_USERS_JWT_SECRET", "super_secret"), algorithms=["HS256"] ) - if payload["tenant_id"]: + if payload.get("tenant_id"): # SimpleNamespace lets us access dictionary elements like attributes auth_data = SimpleNamespace( id=UUID(payload["user_id"]), @@ -29,9 +29,7 @@ async def get_authenticated_user(authorization: str = Header(...)) -> SimpleName roles=payload["roles"], ) else: - auth_data = SimpleNamespace( - id=UUID(payload["user_id"]), tenant_id=None, roles=payload["roles"] - ) + auth_data = SimpleNamespace(id=UUID(payload["user_id"]), tenant_id=None, roles=[]) return auth_data