Skip to content

Commit e7ee4e1

Browse files
committed
Add logout link to authdemo for testing purposes.
1 parent 2ab9465 commit e7ee4e1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

demos/auth/authdemo.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def __init__(self):
3131
handlers = [
3232
(r"/", MainHandler),
3333
(r"/auth/login", AuthHandler),
34+
(r"/auth/logout", LogoutHandler),
3435
]
3536
settings = dict(
3637
cookie_secret="32oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=",
@@ -51,6 +52,7 @@ class MainHandler(BaseHandler):
5152
def get(self):
5253
name = tornado.escape.xhtml_escape(self.current_user["name"])
5354
self.write("Hello, " + name)
55+
self.write("<br><br><a href=\"/auth/logout\">Log out</a>")
5456

5557

5658
class AuthHandler(BaseHandler, tornado.auth.GoogleMixin):
@@ -67,6 +69,10 @@ def _on_auth(self, user):
6769
self.set_secure_cookie("user", tornado.escape.json_encode(user))
6870
self.redirect("/")
6971

72+
class LogoutHandler(BaseHandler):
73+
def get(self):
74+
self.clear_cookie("user")
75+
self.redirect("/")
7076

7177
def main():
7278
tornado.options.parse_command_line()

0 commit comments

Comments
 (0)