Merge pull request #275 from tmuncks/dont-revoke-your-own-rights

Fix user deletion
This commit is contained in:
Khanh Ngo 2018-06-08 09:16:49 +07:00 committed by GitHub
commit ecdb9b9328
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1101,9 +1101,9 @@ def admin_manageuser():
data = jdata['data']
if jdata['action'] == 'delete_user':
if username == current_user.username:
return make_response(jsonify( { 'status': 'error', 'msg': 'You cannot delete yourself.' } ), 400)
user = User(username=data)
if user.username == current_user.username:
return make_response(jsonify( { 'status': 'error', 'msg': 'You cannot delete yourself.' } ), 400)
result = user.delete()
if result:
history = History(msg='Delete username {0}'.format(data), created_by=current_user.username)