overleaf/services/web/scripts/disconnect_all_users.js
June Kelly 49ac6e2e6b Merge pull request #4929 from overleaf/jk-fix-disconnect-users
Fix /disconnectAllUsers endpoint security

GitOrigin-RevId: 57858daa5a076c37332bc575e76ffd6b1a1bd914
2021-09-27 08:02:57 +00:00

20 lines
649 B
JavaScript

const AdminController = require('../app/src/Features/ServerAdmin/AdminController')
if (require.main === module) {
if (['--help', 'help'].includes(process.argv[2])) {
console.log('\n usage: node disconnect_all_users.js [delay-in-seconds]\n')
process.exit(1)
}
const delaySecondsString = process.argv[2]
const delay = parseInt(delaySecondsString, 10) || 10
console.log(`Disconnect all users, with delay ${delay}`)
AdminController._sendDisconnectAllUsersMessage(delay)
.then(() => {
console.error('Done.')
process.exit(0)
})
.catch(err => {
console.error('Error', err)
process.exit(1)
})
}