fix: define MFA helper before use
This commit is contained in:
parent
2aaa0cdd1a
commit
0340873d91
1 changed files with 11 additions and 11 deletions
|
|
@ -34,6 +34,17 @@ await page.setViewportSize({ width: cfg.width, height: cfg.height }); // workaro
|
|||
const notify_games = [];
|
||||
let user;
|
||||
|
||||
const handleMFA = async p => {
|
||||
const otpField = p.locator('#auth-mfa-otpcode, input[name=otpCode]');
|
||||
if (!await otpField.count()) return false;
|
||||
console.log('Two-Step Verification - enter the One Time Password (OTP), e.g. generated by your Authenticator App');
|
||||
await p.locator('#auth-mfa-remember-device, [name=rememberDevice]').check().catch(() => {});
|
||||
const otp = cfg.pg_otpkey && authenticator.generate(cfg.pg_otpkey) || await prompt({ type: 'text', message: 'Enter two-factor sign in code', validate: n => n.toString().length == 6 || 'The code must be 6 digits!' }); // can't use type: 'number' since it strips away leading zeros and codes sometimes have them
|
||||
await otpField.first().pressSequentially(otp.toString());
|
||||
await p.locator('input[type="submit"], button[type="submit"]').first().click();
|
||||
return true;
|
||||
};
|
||||
|
||||
const waitForSignedInOrMFA = async p => {
|
||||
const otpLocator = p.locator('#auth-mfa-otpcode, input[name=otpCode]');
|
||||
const waitSignedIn = p.waitForURL('**/claims/**signedIn=true', { timeout: cfg.login_timeout }).then(() => true).catch(() => false);
|
||||
|
|
@ -54,17 +65,6 @@ const waitForSignedInOrMFA = async p => {
|
|||
await Promise.race([waitSignedIn, waitMFA]);
|
||||
};
|
||||
|
||||
const handleMFA = async p => {
|
||||
const otpField = p.locator('#auth-mfa-otpcode, input[name=otpCode]');
|
||||
if (!await otpField.count()) return false;
|
||||
console.log('Two-Step Verification - enter the One Time Password (OTP), e.g. generated by your Authenticator App');
|
||||
await p.locator('#auth-mfa-remember-device, [name=rememberDevice]').check().catch(() => {});
|
||||
const otp = cfg.pg_otpkey && authenticator.generate(cfg.pg_otpkey) || await prompt({ type: 'text', message: 'Enter two-factor sign in code', validate: n => n.toString().length == 6 || 'The code must be 6 digits!' }); // can't use type: 'number' since it strips away leading zeros and codes sometimes have them
|
||||
await otpField.first().pressSequentially(otp.toString());
|
||||
await p.locator('input[type="submit"], button[type="submit"]').first().click();
|
||||
return true;
|
||||
};
|
||||
|
||||
try {
|
||||
await page.goto(URL_CLAIM, { waitUntil: 'domcontentloaded' }); // default 'load' takes forever
|
||||
const handleDirectLoginPage = async () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue