mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-18 06:24:23 +01:00
Don't allow admins to delete themselves (#1759)
* Don't allow admins to accidentally delete themselves
This commit is contained in:
@@ -250,6 +250,13 @@ class UserPublic(Resource):
|
||||
responses={200: ("Success", "APISimpleSuccessResponse")},
|
||||
)
|
||||
def delete(self, user_id):
|
||||
# Admins should not be able to delete themselves
|
||||
if user_id == session["id"]:
|
||||
return (
|
||||
{"success": False, "errors": {"id": "You cannot delete yourself"}},
|
||||
400,
|
||||
)
|
||||
|
||||
Notifications.query.filter_by(user_id=user_id).delete()
|
||||
Awards.query.filter_by(user_id=user_id).delete()
|
||||
Unlocks.query.filter_by(user_id=user_id).delete()
|
||||
|
||||
Reference in New Issue
Block a user