summaryrefslogtreecommitdiff
path: root/routes.py
diff options
context:
space:
mode:
authorJari Wiik <jwiik@local>2023-11-16 22:46:25 +0200
committerJari Wiik <jwiik@local>2023-11-16 22:46:25 +0200
commitcaae3944492b43e470babc500b913e285bf1ea88 (patch)
tree03f5e2273496398f93f51dec1780f4528d0c3b98 /routes.py
parent0ed244ef2dd27a835ec12fdbc93a1f20bbcd89eb (diff)
Fix lock-up situation when database gets zapped while session is still on
Diffstat (limited to 'routes.py')
-rw-r--r--routes.py14
1 files changed, 10 insertions, 4 deletions
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(),