Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a9986476d0 |
5
app.py
5
app.py
@ -120,6 +120,11 @@ def admin():
|
|||||||
user = User.query.get(user_id)
|
user = User.query.get(user_id)
|
||||||
|
|
||||||
if user and user != current_user: # Prevent self-modification
|
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":
|
if action == "promote":
|
||||||
user.admin = True
|
user.admin = True
|
||||||
elif action == "demote":
|
elif action == "demote":
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
</li>
|
</li>
|
||||||
<li class="list-group-item d-flex justify-content-between">
|
<li class="list-group-item d-flex justify-content-between">
|
||||||
<span>Account Created:</span>
|
<span>Account Created:</span>
|
||||||
<span class="text-muted">Just now</span>
|
<span class="text-muted">Before the dinosaurs, there was your account</span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user