mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-04-07 00:15:23 +02:00
Merge 8ad2fbed1b into 8ed0bcf5ca
This commit is contained in:
commit
0b4488b848
1 changed files with 26 additions and 9 deletions
|
|
@ -44,12 +44,24 @@ async function gracefulExit(code = 0) {
|
|||
(async () => {
|
||||
await connect();
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
let yesCount = 0;
|
||||
const filteredArgs = args.filter((arg) => {
|
||||
if (arg === '-y') {
|
||||
yesCount++;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
const confirmDelete = yesCount >= 1;
|
||||
const confirmTxDelete = yesCount >= 2;
|
||||
|
||||
console.purple('---------------');
|
||||
console.purple('Deleting a user and all related data');
|
||||
console.purple('---------------');
|
||||
|
||||
// 1) Get email
|
||||
let email = process.argv[2]?.trim();
|
||||
let email = filteredArgs[0]?.trim();
|
||||
if (!email) {
|
||||
email = (await askQuestion('Email:')).trim();
|
||||
}
|
||||
|
|
@ -62,17 +74,22 @@ async function gracefulExit(code = 0) {
|
|||
}
|
||||
|
||||
// 3) Confirm full deletion
|
||||
const confirmAll = await askQuestion(
|
||||
`Really delete user ${user.email} (${user._id}) and ALL their data? (y/N)`,
|
||||
);
|
||||
if (confirmAll.toLowerCase() !== 'y') {
|
||||
console.yellow('Aborted.');
|
||||
return gracefulExit(0);
|
||||
if (!confirmDelete) {
|
||||
const confirmAll = await askQuestion(
|
||||
`Really delete user ${user.email} (${user._id}) and ALL their data? (y/N)`,
|
||||
);
|
||||
if (confirmAll.toLowerCase() !== 'y') {
|
||||
console.yellow('Aborted.');
|
||||
return gracefulExit(0);
|
||||
}
|
||||
}
|
||||
|
||||
// 4) Ask specifically about transactions
|
||||
const confirmTx = await askQuestion('Also delete all transaction history for this user? (y/N)');
|
||||
const deleteTx = confirmTx.toLowerCase() === 'y';
|
||||
let deleteTx = confirmTxDelete;
|
||||
if (!confirmTxDelete) {
|
||||
const confirmTx = await askQuestion('Also delete all transaction history for this user? (y/N)');
|
||||
deleteTx = confirmTx.toLowerCase() === 'y';
|
||||
}
|
||||
|
||||
const uid = user._id.toString();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue