From afbae819c9880725141e18f857f8b8d8e3f4795e Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Fri, 17 Nov 2023 12:08:13 +1100 Subject: [PATCH] feat: Allow admin to delete any link --- db.py | 8 ++++++++ main.py | 6 ++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/db.py b/db.py index 0d3b8fb..0d3d2ca 100644 --- a/db.py +++ b/db.py @@ -168,4 +168,12 @@ def delete_link(url,domain): cursor.execute("DELETE FROM links WHERE url=%s AND owner=%s", (url,domain)) connection.commit() cursor.close() + connection.close() + +def delete_link_admin(url): + connection = mysql.connector.connect(**dbargs) + cursor = connection.cursor() + cursor.execute("DELETE FROM links WHERE url=%s", (url,)) + connection.commit() + cursor.close() connection.close() \ No newline at end of file diff --git a/main.py b/main.py index c8af825..3079837 100644 --- a/main.py +++ b/main.py @@ -145,8 +145,10 @@ def delete(path): resp = make_response(redirect('/')) resp.set_cookie('linkr', '', expires=0) return resp - - db.delete_link(path,domain) + if domain.lower() != ADMIN_DOMAIN: + db.delete_link(path,domain) + else: + db.delete_link_admin(path,domain) return redirect('/dash')