Fixed scopes and added more specific logs/errors

This commit is contained in:
Omar Richardson
2020-11-23 13:26:36 +01:00
parent d5e7a42135
commit d7d27ad97a
4 changed files with 31 additions and 29 deletions

View File

@@ -28,7 +28,6 @@ class SelfAPIHandler(APIHandler):
Based on the authentication info. Acts as a 'whoami' for auth tokens.
"""
# @needs_scope('read:users') # Should be read:users:user=username
async def get(self):
user = self.current_user
if user is None:
@@ -36,6 +35,8 @@ class SelfAPIHandler(APIHandler):
user = self.get_current_user_oauth_token()
if user is None:
raise web.HTTPError(403)
# Later: filter based on scopes.
# Perhaps user
self.write(json.dumps(self.user_model(user)))
@@ -48,7 +49,7 @@ class UserListAPIHandler(APIHandler):
]
self.write(json.dumps(data))
@needs_scope('users')
@needs_scope('admin:users')
async def post(self):
data = self.get_json_body()
if not data or not isinstance(data, dict) or not data.get('usernames'):