mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #1780 from overleaf/sk-script-remove-password-fields
Add a script to remove `hashedPassword` fields from non-sl user records GitOrigin-RevId: d7c6fdbc138d4c5452e6e3a7f2ad639f049f122f
This commit is contained in:
parent
3486f61b5b
commit
02c4edcb1c
1 changed files with 40 additions and 0 deletions
|
@ -0,0 +1,40 @@
|
|||
const { db } = require('../app/js/infrastructure/mongojs')
|
||||
const minimist = require('minimist')
|
||||
|
||||
const argv = minimist(process.argv.slice(2))
|
||||
const commit = argv.commit !== undefined
|
||||
|
||||
if (!commit) {
|
||||
console.log('DOING DRY RUN. TO SAVE CHANGES PASS --commit')
|
||||
}
|
||||
|
||||
function main(callback) {
|
||||
const query = { 'overleaf.id': { $exists: true } }
|
||||
db.users.count(query, (err, result) => {
|
||||
if (err) {
|
||||
return callback(err)
|
||||
}
|
||||
console.log(`>> Count: ${result}`)
|
||||
if (!commit) {
|
||||
return callback()
|
||||
}
|
||||
db.users.update(query, { $unset: { hashedPassword: 1 } }, (err, result) => {
|
||||
if (err) {
|
||||
return callback(err)
|
||||
}
|
||||
console.log(`>> Updated users: ${JSON.stringify(result)}`)
|
||||
return callback()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
main(err => {
|
||||
if (err) {
|
||||
console.error(err)
|
||||
return process.exit(1)
|
||||
}
|
||||
console.log('>> done')
|
||||
process.exit(0)
|
||||
})
|
||||
}
|
Loading…
Reference in a new issue