fix: Resolve issue with UI auth (#900)
<!-- .github/pull_request_template.md --> ## Description <!-- Provide a clear description of the changes in this PR --> ## 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.
This commit is contained in:
parent
0dc0c3ccdf
commit
1a9cf903fd
1 changed files with 2 additions and 4 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue