2024-10-18 07:04:57 -04:00
|
|
|
import { waitForDb } from '../app/src/infrastructure/mongodb.js'
|
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 { ensureRunningOnMongoSecondaryWithTimeout } from './helpers/env_variable_helper.mjs'
|
2022-06-07 10:31:59 -04:00
|
|
|
|
2024-10-18 07:04:57 -04:00
|
|
|
ensureRunningOnMongoSecondaryWithTimeout(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('Checking SSO user ID migration for 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.checkMigration(institutionId)
|
2022-06-07 10:31:59 -04:00
|
|
|
|
|
|
|
if (emitUsers) {
|
|
|
|
console.log(
|
2022-11-14 10:07:44 -05:00
|
|
|
`\nMigrated: ${result.migrated}\nNot migrated: ${result.notMigrated}\nMultiple Identifiers: ${result.multipleIdentifiers}`
|
2022-06-07 10:31:59 -04:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log(
|
2022-11-14 10:07:44 -05:00
|
|
|
`\nMigrated: ${result.migrated.length}\nNot migrated: ${result.notMigrated.length}\nMultiple Identifiers: ${result.multipleIdentifiers.length}`
|
2022-06-07 10:31:59 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
process.exit()
|
|
|
|
}
|