From caae3944492b43e470babc500b913e285bf1ea88 Mon Sep 17 00:00:00 2001 From: Jari Wiik Date: Thu, 16 Nov 2023 22:46:25 +0200 Subject: Fix lock-up situation when database gets zapped while session is still on --- routes.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'routes.py') diff --git a/routes.py b/routes.py index 7e7f2ca..144eeef 100644 --- a/routes.py +++ b/routes.py @@ -10,8 +10,14 @@ def get_alert(): return "" def get_nick(): - if "id" in session.keys(): - return D.user_get_nick(session["id"]) + while "id" in session.keys(): + nick = D.user_get_nick(session["id"]) + if not nick: + del session['id'] + if "quiz_id" in session.keys(): + del session['quiz_id'] + break + return nick return "(ei nimimerkkiƤ)" @app.route("/") @@ -37,7 +43,7 @@ def create(): @app.route("/pages/answer.html") def answer(): - if "id" not in session: + if "id" not in session.keys(): return "redirect = #nick" return render_template("answer.html", alert=get_alert(), @@ -46,7 +52,7 @@ def answer(): @app.route("/pages/analyse.html") def analyse(): - if "id" not in session: + if "id" not in session.keys(): return "redirect = #nick" return render_template("analyse.html", alert=get_alert(), -- cgit v1.2.3