Use native Chrome for Reddit login handoff

This commit is contained in:
jjbrunton committed 2026-08-08 16:16:11 +01:00
1 parent 2c533fa52a
commit dbb1842ef4
13 files changed
+324 -60

No files matched your search

+11 -13
View File
@@ -41,24 +41,22 @@ export function createLoginRouter(ctx: WebContext): Router {
}
});
// Navigate the headed Chromium running under Xvfb to reddit.com/login so
// the human watching the noVNC stream can complete the flow.
// Restart into a completely native Chrome process. The container supervisor
// does not enable DevTools until the human explicitly completes the handoff.
router.post('/login/start', async (_req, res) => {
const browser = ctx.services.browser;
if (!browser) {
res.status(503).json({ ok: false, error: 'browser not initialised' });
const nativeLogin = ctx.services.nativeLogin;
if (!nativeLogin) {
res.status(503).json({ ok: false, error: 'native login unavailable' });
return;
}
try {
ctx.services.accountAuth?.invalidate('Interactive Reddit login requested');
const page = await browser.getPage();
await page.bringToFront().catch(() => undefined);
await page.goto('https://www.reddit.com/login', { waitUntil: 'domcontentloaded' });
ctx.logger.info('Opened Reddit login page for human completion via VNC');
res.json({ ok: true });
ctx.services.accountAuth?.invalidate('Native Reddit login requested');
nativeLogin.request();
ctx.logger.info('Restarting into native Chrome login mode; bot logic remains locked');
res.status(202).json({ ok: true, restarting: true });
} catch (error) {
ctx.logger.error('Failed to open login page:', error);
res.status(500).json({ ok: false, error: 'navigation failed' });
ctx.logger.error('Failed to start native login mode:', error);
res.status(500).json({ ok: false, error: 'handoff failed' });
}
});