From c9bb96d2bee3336cab898dd381616b4302c3552d Mon Sep 17 00:00:00 2001 From: Sabe Jones Date: Wed, 19 Feb 2020 20:04:17 +0000 Subject: [PATCH] fix(gdpr): unique key fix --- scripts/gdpr-delete-users.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/gdpr-delete-users.js b/scripts/gdpr-delete-users.js index 954f6bf8f8..e58ccdcb56 100644 --- a/scripts/gdpr-delete-users.js +++ b/scripts/gdpr-delete-users.js @@ -34,11 +34,12 @@ async function deleteAmplitudeData (userId, email) { } async function deleteHabiticaData (user, email) { + const truncatedEmail = email.slice(0, email.indexOf('@')); await User.update( { _id: user._id }, { $set: { - 'auth.local.email': email, + 'auth.local.email': user.auth.local.email ? email : `${truncatedEmail}@habitica.com`, 'auth.local.hashed_password': '$2a$10$QDnNh1j1yMPnTXDEOV38xOePEWFd4X8DSYwAM8XTmqmacG5X0DKjW', 'auth.local.passwordHashMethod': 'bcrypt', },