Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function setupAdmin() {
try {
let adminPassword = process.env['sm.ADMIN_ACCOUNT_PASSWORD']
let storePasswordInSecretsManager
if (!adminPassword) {
adminPassword = crypto.randomBytes(16).toString('base64')
storePasswordInSecretsManager = true
}
await userbaseServer.createAdmin(ADMIN_NAME, adminPassword, ADMIN_ID, storePasswordInSecretsManager)
} catch (e) {
if (!e || e.status !== CONFLICT_STATUS_CODE) {
console.log(`Failed to set up new admin account with ${JSON.stringify(e)}`)
}
}
}