logout.py 785 B

1234567891011121314151617181920212223
  1. """Tornado handlers for logging out of the Jupyter Server."""
  2. # Copyright (c) Jupyter Development Team.
  3. # Distributed under the terms of the Modified BSD License.
  4. from ..base.handlers import JupyterHandler
  5. from .decorator import allow_unauthenticated
  6. class LogoutHandler(JupyterHandler):
  7. """An auth logout handler."""
  8. @allow_unauthenticated
  9. def get(self):
  10. """Handle a logout."""
  11. self.identity_provider.clear_login_cookie(self)
  12. if self.login_available:
  13. message = {"info": "Successfully logged out."}
  14. else:
  15. message = {"warning": "Cannot log out. Jupyter Server authentication is disabled."}
  16. self.write(self.render_template("logout.html", message=message))
  17. default_handlers = [(r"/logout", LogoutHandler)]