mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #16045 from overleaf/revert-16012-jpa-purge-legacy-pw
Revert "[web] purge legacy passwords" GitOrigin-RevId: 59f2094b853139ffa96a6803c97aebe4ba3c35ee
This commit is contained in:
parent
78c1687f3b
commit
92dabf236c
1 changed files with 0 additions and 40 deletions
|
@ -1,40 +0,0 @@
|
|||
const { db, waitForDb } = require('../app/src/infrastructure/mongodb')
|
||||
const { batchedUpdateWithResultHandling } = require('./helpers/batchedUpdate')
|
||||
const { UserAuditLogEntry } = require('../app/src/models/UserAuditLogEntry')
|
||||
const DRY_RUN = process.env.DRY_RUN !== 'false'
|
||||
|
||||
const VARIANTS = [
|
||||
{
|
||||
query: { sharelatexHashedPassword: { $exists: true } },
|
||||
update: { $unset: { sharelatexHashedPassword: true } },
|
||||
},
|
||||
{
|
||||
query: { hashedPassword: { $regex: /^[0-9a-f]{64}$/ } },
|
||||
update: { $unset: { hashedPassword: true } },
|
||||
},
|
||||
]
|
||||
|
||||
if (require.main === module) {
|
||||
batchedUpdateWithResultHandling(
|
||||
'users',
|
||||
{ $or: VARIANTS.map(variant => variant.query) },
|
||||
async users => {
|
||||
const userIds = users.map(user => user._id)
|
||||
if (DRY_RUN) {
|
||||
console.warn(`Running in dry-run mode. Skipping updates for ${userIds}`)
|
||||
return
|
||||
}
|
||||
for (const userId of userIds) {
|
||||
await UserAuditLogEntry.create({
|
||||
userId,
|
||||
operation: 'purge-legacy-password',
|
||||
info: { script: true },
|
||||
})
|
||||
}
|
||||
await waitForDb()
|
||||
for (const { query, update } of VARIANTS) {
|
||||
await db.users.updateMany({ _id: { $in: userIds }, ...query }, update)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
Loading…
Reference in a new issue