From: Ben Darnell Date: Sun, 26 Aug 2012 23:23:30 +0000 (-0700) Subject: Make authdemo's logout less confusing. X-Git-Tag: v2.4.0~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4386f1b0888a5c4a90f5918f547f30ecb42a4baa;p=thirdparty%2Ftornado.git Make authdemo's logout less confusing. Closes #376. --- diff --git a/demos/auth/authdemo.py b/demos/auth/authdemo.py index 0196a3be7..cca7d3786 100755 --- a/demos/auth/authdemo.py +++ b/demos/auth/authdemo.py @@ -62,17 +62,24 @@ class AuthHandler(BaseHandler, tornado.auth.GoogleMixin): self.get_authenticated_user(self.async_callback(self._on_auth)) return self.authenticate_redirect() - + 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.redirect("/") + class LogoutHandler(BaseHandler): def get(self): + # This logs the user out of this demo app, but does not log them + # out of Google. Since Google remembers previous authorizations, + # 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.redirect("/") + self.write('You are now logged out. ' + 'Click here to log back in.') def main(): tornado.options.parse_command_line()