blurts-server/scripts/delete-user.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 строки
963 B
JavaScript
Исходник Обычный вид История

'use strict'
const readline = require('readline')
const DB = require('../db/DB')
2022-10-04 19:58:03 +03:00
/**
* OBSOLETE
* One-off script that deletes a subscriber record from the subscriber table
*/
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
(async () => {
2022-10-04 19:58:03 +03:00
rl.question('What FXA primary email address? ', firstAnswer => {
rl.question('Please re-type the email address to confirm. ', async (secondAnswer) => {
if (firstAnswer !== secondAnswer) {
console.error('Email addresses do not match.')
process.exit(1)
}
2022-10-18 04:51:44 +03:00
const subscriber = await DB.getSubscriberByEmail(secondAnswer)
if (!subscriber) {
console.error('Could not find subscriber.')
process.exit(1)
}
await DB.deleteEmailAddressesByUid(subscriber.id)
2023-05-22 23:12:55 +03:00
await DB.deleteSubscriber(subscriber)
console.log('Deleted email_addresses and subscribers records.')
process.exit()
})
})
})()