mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #1859 from overleaf/spd-sl-user-password-copy
Copy old SL hashed passwords to a new field GitOrigin-RevId: 28e7ff57e8753a1e887c54e9ed63cb17984e2fd4
This commit is contained in:
parent
3ce74a3877
commit
93386bcb8c
2 changed files with 43 additions and 0 deletions
|
@ -97,6 +97,9 @@ const UserSchema = new Schema({
|
|||
default: Settings.defaultFeatures.referencesSearch
|
||||
}
|
||||
},
|
||||
// when auto-merged from SL and must-reconfirm is set, we may end up using
|
||||
// `sharelatexHashedPassword` to recover accounts...
|
||||
sharelatexHashedPassword: String,
|
||||
must_reconfirm: { type: Boolean, default: false },
|
||||
referal_id: {
|
||||
type: String,
|
||||
|
|
40
services/web/scripts/copy_old_sharelatex_passwords.js
Normal file
40
services/web/scripts/copy_old_sharelatex_passwords.js
Normal file
|
@ -0,0 +1,40 @@
|
|||
const { db } = require('../app/src/infrastructure/mongojs')
|
||||
const Async = require('async')
|
||||
const minimist = require('minimist')
|
||||
|
||||
const argv = minimist(process.argv.slice(2))
|
||||
const limit = argv.limit
|
||||
|
||||
if (!limit) {
|
||||
console.log('Please supply an async limit with --limit')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
db.users.find(
|
||||
{ hashedPassword: { $exists: 1 }, sharelatexHashedPassword: { $exists: 0 } },
|
||||
{ hashedPassword: 1 },
|
||||
(err, users) => {
|
||||
if (err) {
|
||||
throw err
|
||||
}
|
||||
|
||||
Async.eachLimit(
|
||||
users,
|
||||
limit,
|
||||
(user, cb) => {
|
||||
db.users.update(
|
||||
{ _id: user._id },
|
||||
{ $set: { sharelatexHashedPassword: user.hashedPassword } },
|
||||
cb
|
||||
)
|
||||
},
|
||||
err => {
|
||||
if (err) {
|
||||
throw err
|
||||
}
|
||||
console.log('finished')
|
||||
process.exit(0)
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
Loading…
Reference in a new issue