2024-10-30 10:23:34 -04:00
|
|
|
import SAMLUserIdMigrationHandler from '../modules/saas-authentication/app/src/SAML/SAMLUserIdMigrationHandler.mjs'
|
2024-10-18 07:04:57 -04:00
|
|
|
import { ensureMongoTimeout } from './helpers/env_variable_helper.mjs'
|
|
|
|
|
|
|
|
ensureMongoTimeout(300000)
|
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
|
|
|
|
)
|
|
|
|
|
|
|
|
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()
|
|
|
|
}
|
2024-10-18 07:04:57 -04:00
|
|
|
|
|
|
|
try {
|
|
|
|
await main()
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error)
|
|
|
|
process.exit(1)
|
|
|
|
}
|