2022-10-17 06:13:35 -04:00
|
|
|
process.env.MONGO_SOCKET_TIMEOUT = '300000'
|
2022-06-07 10:31:59 -04:00
|
|
|
const { waitForDb } = require('../app/src/infrastructure/mongodb')
|
2024-08-22 10:25:00 -04:00
|
|
|
const SAMLUserIdMigrationHandler = require('../modules/saas-authentication/app/src/SAML/SAMLUserIdMigrationHandler')
|
2022-06-07 10:31:59 -04:00
|
|
|
|
|
|
|
const institutionId = parseInt(process.argv[2])
|
|
|
|
if (isNaN(institutionId)) throw new Error('No institution id')
|
|
|
|
const emitUsers = process.argv.includes('--emit-users')
|
|
|
|
|
|
|
|
console.log(
|
|
|
|
'Remove SSO linking for users not migrated at institution:',
|
|
|
|
institutionId
|
|
|
|
)
|
|
|
|
|
|
|
|
waitForDb()
|
|
|
|
.then(main)
|
|
|
|
.catch(error => {
|
|
|
|
console.error(error)
|
|
|
|
process.exit(1)
|
|
|
|
})
|
|
|
|
|
|
|
|
async function main() {
|
2024-03-25 06:51:40 -04:00
|
|
|
const result =
|
|
|
|
await SAMLUserIdMigrationHandler.promises.removeNotMigrated(institutionId)
|
2022-06-07 10:31:59 -04:00
|
|
|
|
|
|
|
if (emitUsers) {
|
|
|
|
console.log(
|
|
|
|
`\nRemoved: ${result.success}\nFailed to remove: ${result.failed}`
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log(
|
|
|
|
`\nRemoved: ${result.success.length}\nFailed to remove: ${result.failed.length}`
|
|
|
|
)
|
|
|
|
|
|
|
|
process.exit()
|
|
|
|
}
|