feat: Allow admin to delete any link
All checks were successful
Build Docker / Build Main Image (push) Successful in 21s

This commit is contained in:
Nathan Woodburn 2023-11-17 12:08:13 +11:00
parent 3111bf9204
commit afbae819c9
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
2 changed files with 12 additions and 2 deletions

8
db.py
View File

@ -168,4 +168,12 @@ def delete_link(url,domain):
cursor.execute("DELETE FROM links WHERE url=%s AND owner=%s", (url,domain)) cursor.execute("DELETE FROM links WHERE url=%s AND owner=%s", (url,domain))
connection.commit() connection.commit()
cursor.close() 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() connection.close()

View File

@ -145,8 +145,10 @@ def delete(path):
resp = make_response(redirect('/')) resp = make_response(redirect('/'))
resp.set_cookie('linkr', '', expires=0) resp.set_cookie('linkr', '', expires=0)
return resp return resp
if domain.lower() != ADMIN_DOMAIN:
db.delete_link(path,domain) db.delete_link(path,domain)
else:
db.delete_link_admin(path,domain)
return redirect('/dash') return redirect('/dash')