2022-10-17 06:13:35 -04:00
|
|
|
process.env.MONGO_SOCKET_TIMEOUT = '300000'
|
2022-06-07 10:31:59 -04:00
|
|
|
process.env.MONGO_CONNECTION_STRING =
|
|
|
|
process.env.READ_ONLY_MONGO_CONNECTION_STRING
|
|
|
|
|
|
|
|
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('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()
|
|
|
|
}
|