nopaque/web/app/profile/tasks.py
2020-06-05 14:42:04 +02:00

17 lines
468 B
Python

from ..decorators import background
from ..models import User
import os
import shutil
@background
def delete_user(user_id, *args, **kwargs):
app = kwargs['app']
with app.app_context():
user = User.query.get(user_id)
if user is None:
raise Exception('User {} not found!'.format(user_id))
path = os.path.join(app.config['NOPAQUE_STORAGE'], str(user.id))
shutil.rmtree(path, ignore_errors=True)
user.delete()