mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 07:37:25 +01:00
fix(scripts): better error handling for script runner and GDPR
This commit is contained in:
@@ -17,12 +17,12 @@ function setUpServer () {
|
|||||||
setUpServer();
|
setUpServer();
|
||||||
|
|
||||||
// Replace this with your migration
|
// Replace this with your migration
|
||||||
const processUsers = require('./users/takeThis.js');
|
const processUsers = require('../scripts/gdpr-delete-users.js');
|
||||||
processUsers()
|
processUsers()
|
||||||
.then(function success () {
|
.then(function success () {
|
||||||
process.exitCode = 0;
|
process.exit(0);
|
||||||
})
|
})
|
||||||
.catch(function failure (err) {
|
.catch(function failure (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
process.exitCode = 1;
|
process.exit(1);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -20,9 +20,11 @@ async function _deleteAmplitudeData (userId, email) {
|
|||||||
password: AMPLITUDE_SECRET,
|
password: AMPLITUDE_SECRET,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
).catch((err) => {
|
||||||
|
console.log(err.response.data);
|
||||||
|
});
|
||||||
|
|
||||||
console.log(`${response.status} ${response.statusText}`);
|
if (response) console.log(`${response.status} ${response.statusText}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function _deleteHabiticaData (user) {
|
async function _deleteHabiticaData (user) {
|
||||||
@@ -44,11 +46,15 @@ async function _deleteHabiticaData (user) {
|
|||||||
'x-api-key': user.apiToken,
|
'x-api-key': user.apiToken,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
).catch((err) => {
|
||||||
|
console.log(err.response.data);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response) {
|
||||||
console.log(`${response.status} ${response.statusText}`);
|
console.log(`${response.status} ${response.statusText}`);
|
||||||
if (response.status === 200) console.log(`${user._id} removed. Last login: ${user.auth.timestamps.loggedin}`);
|
if (response.status === 200) console.log(`${user._id} removed. Last login: ${user.auth.timestamps.loggedin}`);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function _processEmailAddress (email) {
|
async function _processEmailAddress (email) {
|
||||||
const emailRegex = new RegExp(`^${email}`, 'i');
|
const emailRegex = new RegExp(`^${email}`, 'i');
|
||||||
|
|||||||
Reference in New Issue
Block a user