Skip to content

Commit

Permalink
Delete user from session on remove
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikearaya committed Dec 20, 2024
1 parent 416ed94 commit 5d205c4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions packages/core-users/src/module/configureUsersModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,9 @@ export const configureUsersModule = async ({
},

deletePermanently: async ({ userId }: { userId: string }): Promise<User> => {
await db.collection('sessions').deleteMany({
session: { $regex: `"user":"${userId}"` },
});
return Users.findOneAndDelete({ _id: userId });
},

Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/services/migrateUserData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ export async function migrateUserDataService(userIdBeforeLogin: string, userId:
fromUserId: userIdBeforeLogin,
toUserId: userId,
shouldMerge: userSettings.mergeUserCartsOnLogin,
countryContext: userBeforeLogin.lastLogin?.countryCode || user.lastLogin?.countryCode,
countryContext: userBeforeLogin?.lastLogin?.countryCode || user?.lastLogin?.countryCode,
});

await migrateBookmarksService.bind(this)({
fromUserId: userIdBeforeLogin,
toUserId: userId,
shouldMerge: userSettings.mergeUserCartsOnLogin,
countryContext: userBeforeLogin.lastLogin?.countryCode || user.lastLogin?.countryCode,
countryContext: userBeforeLogin?.lastLogin?.countryCode || user?.lastLogin?.countryCode,
});
}

0 comments on commit 5d205c4

Please sign in to comment.