mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-15 05:53:00 +00:00
Use encoded URL when redirecting user notebooks
Otherwise it breaks for usernames that have url unsafe characters.
This commit is contained in:
@@ -8,17 +8,17 @@ from tornado import web, gen
|
||||
from .. import orm
|
||||
from ..utils import admin_only, url_path_join
|
||||
from .base import BaseHandler
|
||||
from .login import LoginHandler
|
||||
from urllib.parse import quote
|
||||
|
||||
|
||||
class RootHandler(BaseHandler):
|
||||
"""Render the Hub root page.
|
||||
|
||||
|
||||
If logged in, redirects to:
|
||||
|
||||
|
||||
- single-user server if running
|
||||
- hub home, otherwise
|
||||
|
||||
|
||||
Otherwise, renders login page.
|
||||
"""
|
||||
def get(self):
|
||||
@@ -49,9 +49,9 @@ class HomeHandler(BaseHandler):
|
||||
|
||||
class SpawnHandler(BaseHandler):
|
||||
"""Handle spawning of single-user servers via form.
|
||||
|
||||
|
||||
GET renders the form, POST handles form submission.
|
||||
|
||||
|
||||
Only enabled when Spawner.options_form is defined.
|
||||
"""
|
||||
def _render_form(self, message=''):
|
||||
@@ -75,9 +75,11 @@ class SpawnHandler(BaseHandler):
|
||||
self.finish(self._render_form())
|
||||
else:
|
||||
# not running, no form. Trigger spawn.
|
||||
url = url_path_join(self.base_url, 'user', user.name)
|
||||
# Creating the URL manually since the server does not
|
||||
# exist yet
|
||||
url = url_path_join(self.base_url, 'user', quote(user.name))
|
||||
self.redirect(url)
|
||||
|
||||
|
||||
@web.authenticated
|
||||
@gen.coroutine
|
||||
def post(self):
|
||||
@@ -122,14 +124,14 @@ class AdminHandler(BaseHandler):
|
||||
}
|
||||
sorts = self.get_arguments('sort') or default_sort
|
||||
orders = self.get_arguments('order')
|
||||
|
||||
|
||||
for bad in set(sorts).difference(available):
|
||||
self.log.warn("ignoring invalid sort: %r", bad)
|
||||
sorts.remove(bad)
|
||||
for bad in set(orders).difference({'asc', 'desc'}):
|
||||
self.log.warn("ignoring invalid order: %r", bad)
|
||||
orders.remove(bad)
|
||||
|
||||
|
||||
# add default sort as secondary
|
||||
for s in default_sort:
|
||||
if s not in sorts:
|
||||
@@ -139,17 +141,17 @@ class AdminHandler(BaseHandler):
|
||||
orders.append(default_order[col])
|
||||
else:
|
||||
orders = orders[:len(sorts)]
|
||||
|
||||
|
||||
# this could be one incomprehensible nested list comprehension
|
||||
# get User columns
|
||||
cols = [ getattr(orm.User, mapping.get(c, c)) for c in sorts ]
|
||||
# get User.col.desc() order objects
|
||||
ordered = [ getattr(c, o)() for c, o in zip(cols, orders) ]
|
||||
|
||||
|
||||
users = self.db.query(orm.User).order_by(*ordered)
|
||||
users = [ self._user_from_orm(u) for u in users ]
|
||||
running = [ u for u in users if u.running ]
|
||||
|
||||
|
||||
html = self.render_template('admin.html',
|
||||
user=self.get_current_user(),
|
||||
admin_access=self.settings.get('admin_access', False),
|
||||
|
Reference in New Issue
Block a user