fix user delete profile pic

This commit is contained in:
Son NK 2021-01-19 10:47:48 +01:00
parent da53b7fa00
commit 013a94d1e9
2 changed files with 4 additions and 3 deletions

View file

@ -55,12 +55,12 @@ def update_user_info():
if data["profile_picture"] is None:
if user.profile_picture_id:
file = user.profile_picture
user.profile_picture_id = None
db.session.flush()
if file:
File.delete(file.id)
s3.delete(file.path)
user.profile_picture_id = None
db.session.flush()
db.session.flush()
else:
raw_data = base64.decodebytes(data["profile_picture"].encode())
file_path = random_string(30)

View file

@ -30,6 +30,7 @@ from app.email_utils import (
)
from app.extensions import db
from app.models import User, CustomDomain, Alias, Contact, EmailLog
# flake8: noqa: E101, W191
from tests.utils import login