allow LoginHandler to override get_current_user

pull/37/head
Min RK 12 years ago
parent bb01b716e0
commit dbb5e9a107

@ -44,6 +44,24 @@ class LoginHandler(IPythonHandler):
self.redirect(self.get_argument('next', default=self.base_url))
@staticmethod
def get_user(handler):
"""Called by handlers for identifying the current user."""
# Can't call this get_current_user because it will collide when
# called on LoginHandler itself.
user_id = handler.get_secure_cookie(handler.cookie_name)
# For now the user_id should not return empty, but it could eventually
if user_id == '':
user_id = 'anonymous'
if user_id is None:
# prevent extra Invalid cookie sig warnings:
handler.clear_login_cookie()
if not handler.login_available:
user_id = 'anonymous'
return user_id
@classmethod
def validate_notebook_app_security(cls, notebook_app, ssl_options=None):
if not notebook_app.ip:

@ -68,16 +68,9 @@ class AuthenticatedHandler(web.RequestHandler):
self.clear_cookie(self.cookie_name)
def get_current_user(self):
user_id = self.get_secure_cookie(self.cookie_name)
# For now the user_id should not return empty, but it could eventually
if user_id == '':
user_id = 'anonymous'
if user_id is None:
# prevent extra Invalid cookie sig warnings:
self.clear_login_cookie()
if not self.login_available:
user_id = 'anonymous'
return user_id
if self.login_handler is None:
return 'anonymous'
return self.login_handler.get_user(self)
@property
def cookie_name(self):

Loading…
Cancel
Save