mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-15 14:03:02 +00:00
reply with full user model in auth handlers
This commit is contained in:
@@ -17,9 +17,7 @@ class TokenAPIHandler(APIHandler):
|
|||||||
orm_token = orm.APIToken.find(self.db, token)
|
orm_token = orm.APIToken.find(self.db, token)
|
||||||
if orm_token is None:
|
if orm_token is None:
|
||||||
raise web.HTTPError(404)
|
raise web.HTTPError(404)
|
||||||
self.write(json.dumps({
|
self.write(json.dumps(self.user_model(orm_token.user)))
|
||||||
'user' : orm_token.user.name,
|
|
||||||
}))
|
|
||||||
|
|
||||||
|
|
||||||
class CookieAPIHandler(APIHandler):
|
class CookieAPIHandler(APIHandler):
|
||||||
@@ -33,9 +31,7 @@ class CookieAPIHandler(APIHandler):
|
|||||||
user = self._user_for_cookie(cookie_name, cookie_value)
|
user = self._user_for_cookie(cookie_name, cookie_value)
|
||||||
if user is None:
|
if user is None:
|
||||||
raise web.HTTPError(404)
|
raise web.HTTPError(404)
|
||||||
self.write(json.dumps({
|
self.write(json.dumps(self.user_model(user)))
|
||||||
'user' : user.name,
|
|
||||||
}))
|
|
||||||
|
|
||||||
|
|
||||||
default_handlers = [
|
default_handlers = [
|
||||||
|
@@ -81,7 +81,7 @@ def test_auth_api(app):
|
|||||||
r = api_request(app, 'authorizations/token', api_token)
|
r = api_request(app, 'authorizations/token', api_token)
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
reply = r.json()
|
reply = r.json()
|
||||||
assert reply['user'] == user.name
|
assert reply['name'] == user.name
|
||||||
|
|
||||||
# check fail
|
# check fail
|
||||||
r = api_request(app, 'authorizations/token', api_token,
|
r = api_request(app, 'authorizations/token', api_token,
|
||||||
|
Reference in New Issue
Block a user