add user list handler, first of many

This commit is contained in:
MinRK
2014-09-13 22:42:07 -07:00
parent 970e4d2ce2
commit 833835b0f3
2 changed files with 69 additions and 3 deletions

View File

@@ -0,0 +1,29 @@
"""Authorization handlers"""
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import json
from ..handlers import BaseHandler
from .. import orm
from ..utils import admin_only
class UserListAPIHandler(BaseHandler):
@admin_only
def get(self):
users = list(self.db.query(orm.User))
data = []
for user in users:
data.append({
'name': user.name,
'server': user.server.base_url if user.server else None,
})
self.write(json.dumps(data))
default_handlers = [
(r"/api/users", UserListAPIHandler),
]