← back to Delivery Address Skill
scripts/restart-login.js
28 lines
// Restart an expired auth flow: reload the platform's login URL and resubmit
// the user's email. Usually auto-fires a FRESH code (which invalidates all
// prior codes — TELL THE USER "newest code wins").
// Usage: node restart-login.js --platform ubereats --user me@example.com --port 9223
const { parseArgs, loadConfig, platform, sessionDir, findTab, dumpState } = require('./lib');
(async () => {
const args = parseArgs(process.argv);
const cfg = loadConfig();
const plat = platform(args.platform || cfg.platform);
const user = args.user || cfg.user_email;
if (!user) { console.error('Need --user <email> (or user_email in config.json)'); process.exit(2); }
const { browser, page } = await findTab(args.port || cfg.cdp_port || 9223, args.match || plat.match);
await page.goto(plat.login, { waitUntil: 'domcontentloaded' });
await page.waitForTimeout(4000);
const emailInput = await page.$(plat.emailField);
if (emailInput) {
await page.fill(plat.emailField, user);
await page.click(plat.emailSubmit);
await page.waitForTimeout(7000);
} else {
console.log('No email input — flow may have skipped straight to a code gate:');
}
await dumpState(page, sessionDir(cfg, args), 'restart');
await browser.close();
})().catch(e => { console.error('ERR', e.message); process.exit(1); });