diff --git a/packages/core-users/src/module/configureUsersModule.ts b/packages/core-users/src/module/configureUsersModule.ts index dfbe23bb6..b44b25e37 100644 --- a/packages/core-users/src/module/configureUsersModule.ts +++ b/packages/core-users/src/module/configureUsersModule.ts @@ -659,6 +659,9 @@ export const configureUsersModule = async ({ }, deletePermanently: async ({ userId }: { userId: string }): Promise => { + await db.collection('sessions').deleteMany({ + session: { $regex: `"user":"${userId}"` }, + }); return Users.findOneAndDelete({ _id: userId }); }, diff --git a/packages/core/src/services/migrateUserData.ts b/packages/core/src/services/migrateUserData.ts index edb281168..babb46921 100644 --- a/packages/core/src/services/migrateUserData.ts +++ b/packages/core/src/services/migrateUserData.ts @@ -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, }); }