overleaf/services/web/scripts/remove_oauth_application.js
ilkin-overleaf 3472a82ac9 Merge pull request #11960 from overleaf/jk-script-to-remove-oauth-application
[web] script to remove oauthApplication record

GitOrigin-RevId: d217bec8d4b271ec8007ea90c0fde5e8f7e3fe52
2023-03-01 09:02:59 +00:00

39 lines
1,014 B
JavaScript

const { OauthApplication } = require('../app/src/models/OauthApplication')
const parseArgs = require('minimist')
const OError = require('@overleaf/o-error')
const { waitForDb } = require('../app/src/infrastructure/mongodb')
async function _removeOauthApplication(appId) {
if (!appId) {
throw new OError('No app id supplied')
}
console.log('Waiting for db...')
await waitForDb()
console.log(`Removing oauthApplication with id=${appId}`)
const result = await OauthApplication.deleteOne({ id: appId })
console.log('Result', result)
}
async function main() {
const argv = parseArgs(process.argv.slice(2), {
string: ['id'],
unknown: function (arg) {
console.error('unrecognised argument', arg)
process.exit(1)
},
})
const appId = argv.id
await _removeOauthApplication(appId)
}
if (require.main === module) {
main()
.then(() => {
console.log('Done')
process.exit(0)
})
.catch(err => {
console.error(err)
process.exit(1)
})
}