From a9986476d0ae0cba6df19e83a4cb1ba6343b2e2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20J=C3=B6nsson?= Date: Mon, 17 Nov 2025 21:20:52 +0100 Subject: [PATCH] added protection against deleting last admin, played around with dashbord for joke --- app.py | 5 +++++ templates/dashboard.html | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 1351c0a..9d6b5de 100644 --- a/app.py +++ b/app.py @@ -120,6 +120,11 @@ def admin(): user = User.query.get(user_id) if user and user != current_user: # Prevent self-modification + if action in ['demote', 'delete'] and user.admin: + admin_count = User.query.filter_by(admin=True).count() + if admin_count == 1: + abort(400, description="Cannot remove last admin") + if action == "promote": user.admin = True elif action == "demote": diff --git a/templates/dashboard.html b/templates/dashboard.html index 7f712ca..ded32b7 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -21,7 +21,7 @@
  • Account Created: - Just now + Before the dinosaurs, there was your account