From 6500962dc4295e7b7316490720a56bb01c325b33 Mon Sep 17 00:00:00 2001 From: 2000-Trek Date: Wed, 14 Jun 2023 18:54:58 +0200 Subject: [PATCH] fixed error in /remove user --- main.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 2ef109f..e23b749 100644 --- a/main.py +++ b/main.py @@ -46,11 +46,11 @@ def list(): @app.route("/list/user", methods=['GET']) def user_info(): - username = '%s' % request.args.get("user") + username = request.args.get("user") c.execute("SELECT * FROM users WHERE username = '%s'" % username) - user = c.fetchall() - if user != []: - user[0] + user_list = c.fetchall() + if user_list != []: + user = user_list[0] c.execute(f"SELECT * FROM tags WHERE userid={user[0]}") tags = c.fetchall() text = "" @@ -66,7 +66,9 @@ def new_user(): @app.route("/removeuser", methods=['GET']) def remove_user(): - user_id = '%s' % request.args.get("id") + user_name = request.args.get("id") + c.execute("SELECT * FROM users WHERE username = '%s'" % user_name) + user_id = c.fetchall()[0][0] c.execute(f"DELETE * FROM tags WHERE userid={user_id}") #Noch eine Bestätigung nötig c.execute(f"DELETE * FROM users WHERE id={user_id}") conn.commit()