mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
a7517eefcb
[web] populate db with collections on import, ahead of waitForDb() call GitOrigin-RevId: 7eb4cd61c2052187acd9947d7060f54d9822d314
43 lines
1 KiB
JavaScript
43 lines
1 KiB
JavaScript
const UserGetter = require('../../../app/src/Features/User/UserGetter')
|
|
const UserDeleter = require('../../../app/src/Features/User/UserDeleter')
|
|
|
|
async function main() {
|
|
const email = (process.argv.slice(2).pop() || '').replace(/^--email=/, '')
|
|
if (!email) {
|
|
console.error(`Usage: node ${__filename} --email=joe@example.com`)
|
|
process.exit(1)
|
|
}
|
|
|
|
await new Promise((resolve, reject) => {
|
|
UserGetter.getUser({ email }, { _id: 1 }, function (error, user) {
|
|
if (error) {
|
|
return reject(error)
|
|
}
|
|
if (!user) {
|
|
console.log(
|
|
`user ${email} not in database, potentially already deleted`
|
|
)
|
|
return resolve()
|
|
}
|
|
const options = {
|
|
ipAddress: '0.0.0.0',
|
|
}
|
|
UserDeleter.deleteUser(user._id, options, function (err) {
|
|
if (err) {
|
|
return reject(err)
|
|
}
|
|
resolve()
|
|
})
|
|
})
|
|
})
|
|
}
|
|
|
|
main()
|
|
.then(() => {
|
|
console.error('Done.')
|
|
process.exit(0)
|
|
})
|
|
.catch(err => {
|
|
console.error(err)
|
|
process.exit(1)
|
|
})
|