mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
remove sharelatex auth
GitOrigin-RevId: 7c72b7f80ff0b15d994423f552c67359cac03634
This commit is contained in:
parent
8cc9bc5335
commit
aec0ea5b08
1 changed files with 0 additions and 83 deletions
|
@ -1,83 +0,0 @@
|
|||
/**
|
||||
* create backing accounts for sl users without an overleaf.id
|
||||
*
|
||||
* run with:
|
||||
* node scripts/create_backing_accounts_for_sl_users.js --async-limit=8 --commit
|
||||
*
|
||||
* async-limit is the number of concurrent users to process.
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
const SharelatexAuthHandler = require('../modules/overleaf-integration/app/src/SharelatexAuth/SharelatexAuthHandler')
|
||||
const UserUpdater = require('../app/src/Features/User/UserUpdater')
|
||||
const async = require('async')
|
||||
const { db } = require('../app/src/infrastructure/mongojs')
|
||||
const logger = require('logger-sharelatex')
|
||||
const minimist = require('minimist')
|
||||
|
||||
logger.logger.level('error')
|
||||
|
||||
const argv = minimist(process.argv.slice(2))
|
||||
const commit = argv.commit !== undefined
|
||||
const asyncLimit = parseInt(argv['async-limit']) || 1
|
||||
|
||||
if (asyncLimit === 1) {
|
||||
console.log(`running in series. run with --async-limit=n to run in parallel.`)
|
||||
}
|
||||
|
||||
if (!commit) {
|
||||
console.log(`doing dry run. run with --commit to save changes`)
|
||||
}
|
||||
|
||||
const query = { 'overleaf.id': { $exists: false } }
|
||||
const projection = {
|
||||
email: 1,
|
||||
first_name: 1,
|
||||
hashedPassword: 1,
|
||||
last_name: 1
|
||||
}
|
||||
|
||||
db.users.find(query, projection, (err, users) => {
|
||||
if (err) throw err
|
||||
async.eachLimit(users, asyncLimit, createBackingAccount, err => {
|
||||
if (err) throw err
|
||||
console.log('DONE')
|
||||
process.exit()
|
||||
})
|
||||
})
|
||||
|
||||
function createBackingAccount(user, cb) {
|
||||
console.log(
|
||||
`Creating backing account for id: ${user._id}, email: ${user.email}`
|
||||
)
|
||||
if (!commit) return cb()
|
||||
SharelatexAuthHandler.createBackingAccount(user, (err, v1Profile) => {
|
||||
if (err) {
|
||||
console.error(
|
||||
`Error creating backing account for id: ${user._id}`,
|
||||
err.stack
|
||||
)
|
||||
return cb()
|
||||
}
|
||||
console.log(
|
||||
`Created backing account for id: ${user._id}, ol id: ${
|
||||
v1Profile.id
|
||||
} -- updating user`
|
||||
)
|
||||
const update = {
|
||||
$set: {
|
||||
'overleaf.id': v1Profile.id,
|
||||
'ace.overallTheme': 'light-'
|
||||
}
|
||||
}
|
||||
UserUpdater.updateUser(user._id, update, err => {
|
||||
if (err) {
|
||||
console.error(`Error updating user id: ${user._id}`, err.stack)
|
||||
return cb()
|
||||
}
|
||||
console.log(`Updated user id: ${user._id}`)
|
||||
cb()
|
||||
})
|
||||
})
|
||||
}
|
Loading…
Reference in a new issue