fix(script): better dupe matching

This commit is contained in:
Sabe Jones
2020-07-02 20:56:19 +00:00
parent e36a91a5c7
commit a378106851

View File

@@ -35,15 +35,14 @@ async function deleteAmplitudeData (userId, email) {
async function deleteHabiticaData (user, email) { async function deleteHabiticaData (user, email) {
const truncatedEmail = email.slice(0, email.indexOf('@')); const truncatedEmail = email.slice(0, email.indexOf('@'));
const set = {
'auth.local.hashed_password': '$2a$10$QDnNh1j1yMPnTXDEOV38xOePEWFd4X8DSYwAM8XTmqmacG5X0DKjW',
'auth.local.passwordHashMethod': 'bcrypt',
};
if (!user.auth.local.email) set['auth.local.email'] = `${truncatedEmail}@example.com`;
await User.update( await User.update(
{ _id: user._id }, { _id: user._id },
{ { $set: set },
$set: {
'auth.local.email': user.auth.local.email ? email : `${truncatedEmail}@example.com`,
'auth.local.hashed_password': '$2a$10$QDnNh1j1yMPnTXDEOV38xOePEWFd4X8DSYwAM8XTmqmacG5X0DKjW',
'auth.local.passwordHashMethod': 'bcrypt',
},
},
); );
const response = await axios.delete( const response = await axios.delete(
`${BASE_URL}/api/v3/user`, `${BASE_URL}/api/v3/user`,
@@ -78,6 +77,7 @@ async function processEmailAddress (email) {
const socialUsers = await User.find( const socialUsers = await User.find(
{ {
'auth.local.email': {$not: emailRegex},
$or: [ $or: [
{ 'auth.facebook.emails.value': email }, { 'auth.facebook.emails.value': email },
{ 'auth.google.emails.value': email }, { 'auth.google.emails.value': email },