From 4714e9a277f024141fa30f0ec6739b8acf390331 Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Tue, 1 Dec 2020 19:03:46 +0000 Subject: Add user property to index response --- backend/routes/index.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'backend/routes/index.py') diff --git a/backend/routes/index.py b/backend/routes/index.py index 8144723..b37f381 100644 --- a/backend/routes/index.py +++ b/backend/routes/index.py @@ -18,7 +18,19 @@ class IndexRoute(Route): path = "/" def get(self, request: Request) -> JSONResponse: - return JSONResponse({ + response_data = { "message": "Hello, world!", - "client": request.client.host - }) + "client": request.client.host, + "user": { + "authenticated": False + } + } + + if request.user.is_authenticated: + response_data["user"] = { + "authenticated": True, + "user": request.user.payload, + "scopes": request.auth.scopes + } + + return JSONResponse(response_data) -- cgit v1.2.3