fix: delete profile picture if user gets deleted

This commit is contained in:
Elias Schneider
2025-02-24 09:40:14 +01:00
parent 887c5e462a
commit 9a167d4076
2 changed files with 7 additions and 1 deletions

View File

@@ -128,6 +128,12 @@ func (s *UserService) DeleteUser(userID string) error {
return &common.LdapUserUpdateError{}
}
// Delete the profile picture
profilePicturePath := fmt.Sprintf("%s/profile-pictures/%s.png", common.EnvConfig.UploadPath, userID)
if err := os.Remove(profilePicturePath); err != nil && !os.IsNotExist(err) {
return err
}
return s.db.Delete(&user).Error
}