fix: handle epic MFA code inputs with multiple fields
This commit is contained in:
parent
943fdbbf0c
commit
2592de2285
1 changed files with 10 additions and 1 deletions
|
|
@ -146,7 +146,16 @@ const ensureLoggedIn = async (page, context) => {
|
|||
try {
|
||||
await page.waitForURL('**/id/login/mfa**', { timeout: cfg.login_timeout });
|
||||
const otp = cfg.eg_otpkey && authenticator.generate(cfg.eg_otpkey) || await prompt({ type: 'text', message: 'Enter two-factor sign in code', validate: n => n.toString().length == 6 || 'The code must be 6 digits!' });
|
||||
await page.locator('input[name="code-input-0"]').pressSequentially(otp.toString());
|
||||
const codeInputs = page.locator('input[name^="code-input"]');
|
||||
if (await codeInputs.count()) {
|
||||
const digits = otp.toString().split('');
|
||||
for (let i = 0; i < digits.length; i++) {
|
||||
const input = codeInputs.nth(i);
|
||||
await input.fill(digits[i]);
|
||||
}
|
||||
} else {
|
||||
await page.locator('input[name="code-input-0"]').pressSequentially(otp.toString());
|
||||
}
|
||||
await page.click('button[type="submit"]');
|
||||
} catch {
|
||||
// no MFA
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue