pg: TODO check for wrong credentials

This commit is contained in:
Ralf Vogler 2023-01-25 16:38:56 +01:00
parent 0e7e7b08f3
commit 3b1b900d77

View file

@ -58,6 +58,9 @@ 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');
@ -65,7 +68,7 @@ try {
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.');