logout.py
43 lines
| 1.4 KiB
| text/x-python
|
PythonLexer
Brian E. Granger
|
r10642 | """Tornado handlers for logging out of the notebook. | |
Brian E. Granger
|
r10641 | ||
Authors: | |||
* Brian Granger | |||
""" | |||
#----------------------------------------------------------------------------- | |||
Brian E. Granger
|
r10642 | # Copyright (C) 2011 The IPython Development Team | |
Brian E. Granger
|
r10641 | # | |
# Distributed under the terms of the BSD License. The full license is in | |||
# the file COPYING, distributed as part of this software. | |||
#----------------------------------------------------------------------------- | |||
#----------------------------------------------------------------------------- | |||
# Imports | |||
#----------------------------------------------------------------------------- | |||
Brian E. Granger
|
r10649 | from ..base.handlers import IPythonHandler | |
Brian E. Granger
|
r10641 | ||
#----------------------------------------------------------------------------- | |||
Brian E. Granger
|
r10642 | # Handler | |
Brian E. Granger
|
r10641 | #----------------------------------------------------------------------------- | |
class LogoutHandler(IPythonHandler): | |||
def get(self): | |||
self.clear_login_cookie() | |||
if self.login_available: | |||
message = {'info': 'Successfully logged out.'} | |||
else: | |||
message = {'warning': 'Cannot log out. Notebook authentication ' | |||
'is disabled.'} | |||
self.write(self.render_template('logout.html', | |||
message=message)) | |||
Brian E. Granger
|
r10647 | ||
#----------------------------------------------------------------------------- | |||
# URL to handler mappings | |||
#----------------------------------------------------------------------------- | |||
default_handlers = [(r"/logout", LogoutHandler)] |