Fix admin delete user in AdminUserList.js

This commit is contained in:
Patrick Jentsch 2023-07-26 10:53:34 +02:00
parent 27fe4a95e4
commit 351da5d4e9
2 changed files with 23 additions and 24 deletions

View File

@ -91,8 +91,7 @@ class AdminUserList extends ResourceList {
let listAction = listActionElement === null ? 'view' : listActionElement.dataset.listAction; let listAction = listActionElement === null ? 'view' : listActionElement.dataset.listAction;
switch (listAction) { switch (listAction) {
case 'delete': { case 'delete': {
console.log('delete', itemId); Requests.users.entity.delete(itemId);
Utils.deleteUserRequest(itemId);
if (itemId === currentUserId) {window.location.href = '/';} if (itemId === currentUserId) {window.location.href = '/';}
break; break;
} }

View File

@ -7,29 +7,29 @@ from app.models import Avatar, User
from . import bp from . import bp
# @bp.route('/<hashid:user_id>', methods=['DELETE']) @bp.route('/<hashid:user_id>', methods=['DELETE'])
# @content_negotiation(produces='application/json') @content_negotiation(produces='application/json')
# def delete_user(user_id): def delete_user(user_id):
# def _delete_user(app, user_id): def _delete_user(app, user_id):
# with app.app_context(): with app.app_context():
# user = User.query.get(user_id) user = User.query.get(user_id)
# user.delete() user.delete()
# db.session.commit() db.session.commit()
# user = User.query.get_or_404(user_id) user = User.query.get_or_404(user_id)
# if not (user == current_user or current_user.is_administrator()): if not (user == current_user or current_user.is_administrator()):
# abort(403) abort(403)
# thread = Thread( thread = Thread(
# target=_delete_user, target=_delete_user,
# args=(current_app._get_current_object(), user.id) args=(current_app._get_current_object(), user.id)
# ) )
# if user == current_user: if user == current_user:
# logout_user() logout_user()
# thread.start() thread.start()
# response_data = { response_data = {
# 'message': f'User "{user.username}" marked for deletion' 'message': f'User "{user.username}" marked for deletion'
# } }
# return response_data, 202 return response_data, 202
# @bp.route('/<hashid:user_id>/avatar', methods=['DELETE']) # @bp.route('/<hashid:user_id>/avatar', methods=['DELETE'])