diff options
author | 2020-12-01 20:25:14 +0000 | |
---|---|---|
committer | 2020-12-01 20:25:14 +0000 | |
commit | 700b504af2e6e1ff0de5246b058928c0cc934be5 (patch) | |
tree | 250826482ce439492adcccbdae2f09e56fa1a44e /backend/routes | |
parent | Update SCHEMA.md (diff) | |
parent | Add user property to index response (diff) |
Merge pull request #12 from python-discord/ks123/admin-authentication
Diffstat (limited to 'backend/routes')
-rw-r--r-- | backend/routes/index.py | 18 |
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) |