added protection against deleting last admin, played around with dashbord for joke
This commit is contained in:
parent
bd611b68c0
commit
a9986476d0
5
app.py
5
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":
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
</li>
|
||||
<li class="list-group-item d-flex justify-content-between">
|
||||
<span>Account Created:</span>
|
||||
<span class="text-muted">Just now</span>
|
||||
<span class="text-muted">Before the dinosaurs, there was your account</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user