mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-14 13:33:00 +00:00
cache get_current_user result
avoids raising an error rendering templates, etc.
This commit is contained in:
@@ -265,10 +265,17 @@ class BaseHandler(RequestHandler):
|
|||||||
|
|
||||||
def get_current_user(self):
|
def get_current_user(self):
|
||||||
"""get current username"""
|
"""get current username"""
|
||||||
user = self.get_current_user_token()
|
if not hasattr(self, '_jupyterhub_user'):
|
||||||
if user is not None:
|
try:
|
||||||
return user
|
user = self.get_current_user_token()
|
||||||
return self.get_current_user_cookie()
|
if user is None:
|
||||||
|
user = self.get_current_user_cookie()
|
||||||
|
self._jupyterhub_user = user
|
||||||
|
except Exception:
|
||||||
|
# don't let errors here raise more than once
|
||||||
|
self._jupyterhub_user = None
|
||||||
|
raise
|
||||||
|
return self._jupyterhub_user
|
||||||
|
|
||||||
def find_user(self, name):
|
def find_user(self, name):
|
||||||
"""Get a user by name
|
"""Get a user by name
|
||||||
|
Reference in New Issue
Block a user