Compare commits
2 commits
f5e404329f
...
2592de2285
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2592de2285 | ||
|
|
943fdbbf0c |
1 changed files with 22 additions and 3 deletions
|
|
@ -127,16 +127,35 @@ const ensureLoggedIn = async (page, context) => {
|
||||||
await page.goto('https://www.epicgames.com/id/login?lang=en-US&noHostRedirect=true&redirectUrl=' + URL_CLAIM, { waitUntil: 'domcontentloaded' });
|
await page.goto('https://www.epicgames.com/id/login?lang=en-US&noHostRedirect=true&redirectUrl=' + URL_CLAIM, { waitUntil: 'domcontentloaded' });
|
||||||
const emailField = page.locator('input[name="email"], input#email');
|
const emailField = page.locator('input[name="email"], input#email');
|
||||||
const passwordField = page.locator('input[name="password"], input#password');
|
const passwordField = page.locator('input[name="password"], input#password');
|
||||||
// Some flows pre-fill email and show only password field
|
const continueBtn = page.locator('button:has-text("Continue"), button[type="submit"]');
|
||||||
if (await emailField.count()) await emailField.fill(cfg.eg_email);
|
|
||||||
|
// step 1: email + continue
|
||||||
|
if (await emailField.count()) {
|
||||||
|
await emailField.fill(cfg.eg_email);
|
||||||
|
await continueBtn.first().click();
|
||||||
|
}
|
||||||
|
|
||||||
|
// step 2: password + submit
|
||||||
await passwordField.waitFor({ timeout: cfg.login_visible_timeout });
|
await passwordField.waitFor({ timeout: cfg.login_visible_timeout });
|
||||||
await passwordField.fill(cfg.eg_password);
|
await passwordField.fill(cfg.eg_password);
|
||||||
|
const rememberMe = page.locator('input[name="rememberMe"], #rememberMe');
|
||||||
|
if (await rememberMe.count()) await rememberMe.check().catch(() => {});
|
||||||
await page.click('button[type="submit"]');
|
await page.click('button[type="submit"]');
|
||||||
|
|
||||||
// MFA step
|
// MFA step
|
||||||
try {
|
try {
|
||||||
await page.waitForURL('**/id/login/mfa**', { timeout: cfg.login_timeout });
|
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!' });
|
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!' });
|
||||||
|
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.locator('input[name="code-input-0"]').pressSequentially(otp.toString());
|
||||||
|
}
|
||||||
await page.click('button[type="submit"]');
|
await page.click('button[type="submit"]');
|
||||||
} catch {
|
} catch {
|
||||||
// no MFA
|
// no MFA
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue