nopaque/app/admin/json_routes.py
2023-03-14 14:24:52 +01:00

23 lines
572 B
Python

from flask import current_app
from threading import Thread
from app import db
from app.models import User
from . import bp
@bp.route('/users/<hashid:user_id>/delete', methods=['DELETE'])
def delete_user(user_id):
def _delete_user(app, user_id):
with app.app_context():
user = User.query.get(user_id)
user.delete()
db.session.commit()
User.query.get_or_404(user_id)
thread = Thread(
target=_delete_user,
args=(current_app._get_current_object(), user_id)
)
thread.start()
return {}, 202