Fix issue where user old photo might not be deleted from filesystem

Fix issue where user old photo might not be deleted from filesystem
This commit is contained in:
João Vitória Silva
2025-11-15 22:03:22 +00:00
parent d0474674a3
commit 22bfd3767e
2 changed files with 8 additions and 10 deletions

View File

@@ -340,8 +340,8 @@ def edit_user(user_id: int, user: users_schema.UserRead, db: Session):
height_before = db_user.height
# If the user photo path is different, delete the user photo in the filesystem
if db_user.photo_path != user.photo_path:
# Check if the photo_path is being updated
if user.photo_path:
# Delete the user photo in the filesystem
users_utils.delete_user_photo_filesystem(db_user.id)
@@ -388,9 +388,7 @@ def edit_user(user_id: int, user: users_schema.UserRead, db: Session):
) from err
def approve_user(
user_id: int, db: Session
):
def approve_user(user_id: int, db: Session):
"""
Approve a user by ID.

View File

@@ -698,6 +698,11 @@ async function submitEditUserForm() {
photo_path: newEditUserPhotoPath.value,
active: newEditUserActive.value
}
if (props.action === 'profile') {
await profile.editProfile(data)
} else {
await users.editUser(data.id, data)
}
if (newEditUserPhotoFile.value) {
try {
if (props.action === 'profile') {
@@ -711,11 +716,6 @@ async function submitEditUserForm() {
)
}
}
if (props.action === 'profile') {
await profile.editProfile(data)
} else {
await users.editUser(data.id, data)
}
if (props.action === 'edit') {
emit('editedUser', data)
}