Skip to content

Commit 5979954

Browse files
authored
Merge pull request #68 from nan-af/afnan
Authentication fully implemented for `GET /users`
2 parents 6d6d328 + d3c9f61 commit 5979954

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

main.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,11 @@ async def root():
502502

503503

504504
@app.get("/users")
505-
async def list_users():
506-
return json2html.convert(users_cache)
505+
async def list_users(token=Depends(oauth2_scheme)):
506+
if users_cache[token]['type'] == 'admin':
507+
return json2html.convert(users_cache)
508+
else:
509+
return 'Unauthorised'
507510

508511

509512
# Case 29: Add user

0 commit comments

Comments
 (0)