This commit is contained in:
daniel31x13 2023-11-06 10:06:14 -05:00
parent 7bdef522c1
commit 9bee9b8ae4

View File

@ -60,7 +60,7 @@ export default async function deleteUserById(
});
// Delete archive folders
removeFolder({ filePath: `archives/${collection.id}` });
await removeFolder({ filePath: `archives/${collection.id}` });
}
// Delete collections after cleaning up related data
@ -69,12 +69,13 @@ export default async function deleteUserById(
});
// Delete subscription
await prisma.subscription.delete({
where: { userId },
});
if (process.env.STRIPE_SECRET_KEY)
await prisma.subscription.delete({
where: { userId },
});
// Delete user's avatar
removeFile({ filePath: `uploads/avatar/${userId}.jpg` });
await removeFile({ filePath: `uploads/avatar/${userId}.jpg` });
// Finally, delete the user
await prisma.user.delete({