From da6b67a1adf525b8c9b8d83ccea9d223c68671a4 Mon Sep 17 00:00:00 2001 From: Eneko Illarramendi Date: Sun, 15 Dec 2019 09:18:06 +0100 Subject: [PATCH] fix: redirect to homepage when no more user_wallets are found --- LNbits/__init__.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/LNbits/__init__.py b/LNbits/__init__.py index 64f52e19..4a16dff0 100644 --- a/LNbits/__init__.py +++ b/LNbits/__init__.py @@ -30,8 +30,8 @@ def home(): @app.route("/deletewallet") def deletewallet(): - theid = request.args.get("usr") - thewal = request.args.get("wal") + user_id = request.args.get("usr") + wallet_id = request.args.get("wal") with Database() as db: db.execute( @@ -42,14 +42,15 @@ def deletewallet(): inkey = 'del:' || w.inkey WHERE id = ? AND user = ? """, - (thewal, theid), + (wallet_id, user_id), ) - next_wallet = db.fetchone("SELECT id FROM wallets WHERE user = ?", (theid,)) - if next_wallet: - return redirect(url_for("wallet", usr=theid, wal=next_wallet[0])) + next_wallet = db.fetchone("SELECT id FROM wallets WHERE user = ?", (user_id,)) - return render_template("index.html") + if next_wallet: + return redirect(url_for("wallet", usr=user_id, wal=next_wallet[0])) + + return redirect(url_for("home")) @app.route("/lnurlwallet")