Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikearaya committed Nov 27, 2024
1 parent eb59395 commit 14b9e76
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions packages/core-users/src/module/configureUsersModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -637,26 +637,26 @@ export const configureUsersModule = async ({
});
if (!existingUser) return null;
const maskedUserData = maskUserPropertyValues(existingUser, context?.userId);
await context.modules.bookmarks.deleteByUserId(userId);
await updateUser({ _id: userId }, { $set: { ...maskedUserData, deleted: new Date() } }, {});
modules.orders.deleteUserCart(userId);

await modules.bookmarks.deleteByUserId(userId);
await modules.orders.deleteUserCart(userId);
await modules.quotations.deleteRequestedUserQuotations(userId);
await modules.enrollments.deleteOpenUserEnrollments(userId);
if (removeUserReviews) await modules.products.reviews.deleteMany({ authorId: userId });
const user = await Users.findOneAndDelete(userFilter);

const ordersCount = modules.orders.count({ userId, includeCarts: true });
const quotationsCount = modules.quotations.count({ userId });
const reviewsCount = modules.products.reviews.count({ authorId: userId });
const enrollmentsCount = modules.enrollments.count({ userId });
const ordersCount = await modules.orders.count({ userId, includeCarts: true });
const quotationsCount = await modules.quotations.count({ userId });
const reviewsCount = await modules.products.reviews.count({ authorId: userId });
const enrollmentsCount = await modules.enrollments.count({ userId });
if (!ordersCount && !reviewsCount && !enrollmentsCount && !quotationsCount) {
await Users.deleteOne({ _id: userId });
}

await emit('USER_REMOVE', {
user: removeConfidentialServiceHashes(user),
user: removeConfidentialServiceHashes(existingUser),
});
return user;
return existingUser;
},

updateProfile: async (
Expand Down

0 comments on commit 14b9e76

Please sign in to comment.