Skip to content

Commit

Permalink
pg: TODO check for wrong credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
vogler committed Jan 25, 2023
1 parent 0e7e7b0 commit 3b1b900
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion prime-gaming.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,17 @@ try {
await page.fill('[name=password]', password);
await page.check('[name=rememberMe]');
await page.click('input[type="submit"]');
page.waitForNavigation({ url: '**/ap/signin**'}).then(async () => { // TODO check for wrong credentials
console.error(await page.locator('.a-alert-content').first().innerText());
}).catch(_ => { });
// handle MFA, but don't await it
page.waitForNavigation({ url: '**/ap/mfa**'}).then(async () => {
console.log('Two-Step Verification - enter the One Time Password (OTP), e.g. generated by your Authenticator App');
await page.check('[name=rememberDevice]');
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 page.type('input[name=otpCode]', otp.toString());
await page.click('input[type="submit"]');
});
}).catch(_ => { });
} else {
if (cfg.headless) {
console.log('Please run `node prime-gaming show` to login in the opened browser.');
Expand Down

0 comments on commit 3b1b900

Please sign in to comment.