diff --git a/src/download-helpers.js b/src/download-helpers.js index df77af4..6a1bf0b 100644 --- a/src/download-helpers.js +++ b/src/download-helpers.js @@ -208,8 +208,9 @@ const basicAuthentication = async (page, overridePage, url, username, password, await page.type('[data-test-subj="password"]', password); await page.click('button[type=submit]'); await page.waitForTimeout(10000); + const tenantSelection = await page.$('Select your tenant'); try { - if (multitenancy === true) { + if (multitenancy === true && tenantSelection !== null) { if (tenant === 'global' || tenant === 'private') { await page.click('label[for=' + tenant + ']'); } else { @@ -227,7 +228,7 @@ const basicAuthentication = async (page, overridePage, url, username, password, exit(1); } - if (multitenancy === true) { + if (multitenancy === true && tenantSelection !== null) { await page.waitForTimeout(5000); await page.click('button[data-test-subj="confirm"]'); await page.waitForTimeout(25000); @@ -235,7 +236,7 @@ const basicAuthentication = async (page, overridePage, url, username, password, await overridePage.goto(url, { waitUntil: 'networkidle0' }); await overridePage.waitForTimeout(5000); - if (multitenancy === true) { + if (multitenancy === true && tenantSelection !== null) { // Check if tenant was selected successfully. if ((await overridePage.$('button[data-test-subj="confirm"]')) !== null) { spinner.fail('Invalid tenant'); @@ -257,8 +258,9 @@ const samlAuthentication = async (page, url, username, password, tenant, multite await page.type('[name="credentials.passcode"]', password); await page.click('[value="Sign in"]') await page.waitForTimeout(timeout); + const tenantSelection = await page.$('Select your tenant'); try { - if (multitenancy === true) { + if (multitenancy === true && tenantSelection !== null) { if (tenant === 'global' || tenant === 'private') { await page.click('label[for=' + tenant + ']'); } else { @@ -275,7 +277,7 @@ const samlAuthentication = async (page, url, username, password, tenant, multite spinner.fail('Invalid username or password'); exit(1); } - if (multitenancy === true) { + if (multitenancy === true && tenantSelection !== null) { await page.waitForTimeout(2000); await page.click('button[data-test-subj="confirm"]'); await page.waitForTimeout(25000); @@ -291,8 +293,9 @@ const cognitoAuthentication = async (page, overridePage, url, username, password await page.type('[name="password"]', password); await page.click('[name="signInSubmitButton"]'); await page.waitForTimeout(timeout); + const tenantSelection = await page.$('Select your tenant'); try { - if (multitenancy === true) { + if (multitenancy === true && tenantSelection !== null) { if (tenant === 'global' || tenant === 'private') { await page.click('label[for=' + tenant + ']'); } else { @@ -309,7 +312,7 @@ const cognitoAuthentication = async (page, overridePage, url, username, password spinner.fail('Invalid username or password'); exit(1); } - if (multitenancy === true) { + if (multitenancy === true && tenantSelection !== null) { await page.waitForTimeout(2000); await page.click('button[data-test-subj="confirm"]'); await page.waitForTimeout(25000); @@ -317,7 +320,7 @@ const cognitoAuthentication = async (page, overridePage, url, username, password await overridePage.goto(url, { waitUntil: 'networkidle0' }); await overridePage.waitForTimeout(5000); - if (multitenancy === true) { + if (multitenancy === true && tenantSelection !== null) { // Check if tenant was selected successfully. if ((await overridePage.$('button[data-test-subj="confirm"]')) !== null) { spinner.fail('Invalid tenant');