def check_login(user_hash_id): if user_hash_id: user_id = user_hash_id.split("|")[0] user = User.get_by_id(int(user_id)) if user and Base.valid_pw(user.username, user.password, user_hash_id): return True, user.username else: return False, None else: return False, None
def get(self): cookie = self.request.cookies.get("user_id") if not cookie: self.write_form() else: [user_id, hash_id] = cookie.split("|") user = User.get_by_id(int(user_id)) if Base.valid_pw(user.username, user.password, cookie): self.redirect("/hw5/welcome") else: self.write_form()