From 920f96db6b052338981cfc30b495b144c85276ed Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Sun, 3 Mar 2013 12:16:03 -0500 Subject: [PATCH] Use distinct cookie names across all the demo apps. --- demos/auth/authdemo.py | 6 +++--- demos/blog/blog.py | 6 +++--- demos/chat/chatdemo.py | 6 +++--- demos/facebook/facebook.py | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/demos/auth/authdemo.py b/demos/auth/authdemo.py index 3e666c88..9585ff1a 100755 --- a/demos/auth/authdemo.py +++ b/demos/auth/authdemo.py @@ -42,7 +42,7 @@ class Application(tornado.web.Application): class BaseHandler(tornado.web.RequestHandler): def get_current_user(self): - user_json = self.get_secure_cookie("user") + user_json = self.get_secure_cookie("authdemo_user") if not user_json: return None return tornado.escape.json_decode(user_json) @@ -66,7 +66,7 @@ class AuthHandler(BaseHandler, tornado.auth.GoogleMixin): def _on_auth(self, user): if not user: raise tornado.web.HTTPError(500, "Google auth failed") - self.set_secure_cookie("user", tornado.escape.json_encode(user)) + self.set_secure_cookie("authdemo_user", tornado.escape.json_encode(user)) self.redirect("/") @@ -77,7 +77,7 @@ class LogoutHandler(BaseHandler): # returning to this app will log them back in immediately with no # interaction (unless they have separately logged out of Google in # the meantime). - self.clear_cookie("user") + self.clear_cookie("authdemo_user") self.write('You are now logged out. ' 'Click here to log back in.') diff --git a/demos/blog/blog.py b/demos/blog/blog.py index f6487bcf..b5317822 100755 --- a/demos/blog/blog.py +++ b/demos/blog/blog.py @@ -69,7 +69,7 @@ class BaseHandler(tornado.web.RequestHandler): return self.application.db def get_current_user(self): - user_id = self.get_secure_cookie("user") + user_id = self.get_secure_cookie("blogdemo_user") if not user_id: return None return self.db.get("SELECT * FROM authors WHERE id = %s", int(user_id)) @@ -170,13 +170,13 @@ class AuthLoginHandler(BaseHandler, tornado.auth.GoogleMixin): return else: author_id = author["id"] - self.set_secure_cookie("user", str(author_id)) + self.set_secure_cookie("blogdemo_user", str(author_id)) self.redirect(self.get_argument("next", "/")) class AuthLogoutHandler(BaseHandler): def get(self): - self.clear_cookie("user") + self.clear_cookie("blogdemo_user") self.redirect(self.get_argument("next", "/")) diff --git a/demos/chat/chatdemo.py b/demos/chat/chatdemo.py index 82aafd65..6c3fcac2 100755 --- a/demos/chat/chatdemo.py +++ b/demos/chat/chatdemo.py @@ -50,7 +50,7 @@ class Application(tornado.web.Application): class BaseHandler(tornado.web.RequestHandler): def get_current_user(self): - user_json = self.get_secure_cookie("user") + user_json = self.get_secure_cookie("chatdemo_user") if not user_json: return None return tornado.escape.json_decode(user_json) @@ -142,13 +142,13 @@ class AuthLoginHandler(BaseHandler, tornado.auth.GoogleMixin): def _on_auth(self, user): if not user: raise tornado.web.HTTPError(500, "Google auth failed") - self.set_secure_cookie("user", tornado.escape.json_encode(user)) + self.set_secure_cookie("chatdemo_user", tornado.escape.json_encode(user)) self.redirect("/") class AuthLogoutHandler(BaseHandler): def get(self): - self.clear_cookie("user") + self.clear_cookie("chatdemo_user") self.write("You are now logged out") diff --git a/demos/facebook/facebook.py b/demos/facebook/facebook.py index 341384c0..e252e298 100755 --- a/demos/facebook/facebook.py +++ b/demos/facebook/facebook.py @@ -55,7 +55,7 @@ class Application(tornado.web.Application): class BaseHandler(tornado.web.RequestHandler): def get_current_user(self): - user_json = self.get_secure_cookie("user") + user_json = self.get_secure_cookie("fbdemo_user") if not user_json: return None return tornado.escape.json_decode(user_json) @@ -92,17 +92,17 @@ class AuthLoginHandler(BaseHandler, tornado.auth.FacebookGraphMixin): self.authorize_redirect(redirect_uri=my_url, client_id=self.settings["facebook_api_key"], extra_params={"scope": "read_stream"}) - + def _on_auth(self, user): if not user: raise tornado.web.HTTPError(500, "Facebook auth failed") - self.set_secure_cookie("user", tornado.escape.json_encode(user)) + self.set_secure_cookie("fbdemo_user", tornado.escape.json_encode(user)) self.redirect(self.get_argument("next", "/")) class AuthLogoutHandler(BaseHandler, tornado.auth.FacebookGraphMixin): def get(self): - self.clear_cookie("user") + self.clear_cookie("fbdemo_user") self.redirect(self.get_argument("next", "/"))