def get(self): user_cookie_hash = self.request.cookies.get("user") if user_cookie_hash: user_identified = auth_helpers.check_secure_val(user_cookie_hash) if user_identified: user = User.get_by_id(int(user_identified)) self.write("<h2>Welcome, %s" % user.username) else: self.redirect("/signup") else: self.redirect("/signup")
def read_secure_cookie(self, name): cookie_val = self.request.cookies.get(name) return cookie_val and auth_helpers.check_secure_val(cookie_val)
def logged_in(self): cookie_val = self.request.cookies.get("logged_in") if cookie_val: return auth_helpers.check_secure_val(cookie_val) == "1" else: return False