aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Joe Banks <[email protected]>2020-12-01 19:03:46 +0000
committerGravatar Joe Banks <[email protected]>2020-12-01 19:03:46 +0000
commit4714e9a277f024141fa30f0ec6739b8acf390331 (patch)
tree250826482ce439492adcccbdae2f09e56fa1a44e
parentAdd JWT authentication middleware to middlewares list (diff)
Add user property to index response
-rw-r--r--backend/routes/index.py18
1 files changed, 15 insertions, 3 deletions
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)