Skip to content

Business operating system for Claude Code — 57 skills, 21 agents, smart daemon. Unified inbox (WhatsApp/Email/Slack/Telegram), autonomous PR merge, full-AWS monitoring, revenue (Stripe+RevenueCat), e-commerce (Shopify), marketing (Klaviyo/Meta/GA4), voice (Bland/ElevenLabs), APM (Datadog/NewRelic/OTEL), YOLO mode.

fix(auth): reuse displayed login code (#742)

Aurora Capitale1d5079da1bc
diff --git a/claude-ops/scripts/account-rotation/rotate.mjs b/claude-ops/scripts/account-rotation/rotate.mjs
index e0f04e7e..1b69adca 100644
--- a/claude-ops/scripts/account-rotation/rotate.mjs
+++ b/claude-ops/scripts/account-rotation/rotate.mjs
@@ -2592,6 +2592,22 @@ async function runAuthFlow(driver, account) {
} else {
log(`[magic-link] Navigating to login link`);
await driver.goto(magicLink);
+ const displayText =
+ (await driver.readPageText?.().catch(() => '')) ||
+ (await driver._page
+ ?.locator('body')
+ .innerText()
+ .catch(() => '')) ||
+ '';
+ const displayedCode = /use verification code to continue/i.test(displayText)
+ ? displayText.match(/\b(\d{6})\b/)?.[1]
+ : null;
+ if (displayedCode && driver._authUrl) {
+ log('[magic-link] Captured displayed verification code — returning to sign-in');
+ await driver.goto(driver._authUrl).catch(() => {});
+ await sleep(2000);
+ return finishMagicLinkLogin(`code:${displayedCode}`);
+ }
}
await sleep(4000);
// After magic link login, session is now valid — re-navigate to authUrl
@@ -2686,6 +2702,18 @@ async function runAuthFlow(driver, account) {
}
}
+ async function finishDisplayedClaudeVerificationCode() {
+ if (!driver.readPageText || !driver._authUrl) return false;
+ const text = await driver.readPageText().catch(() => '');
+ if (!/use verification code to continue/i.test(text)) return false;
+ const code = text.match(/\b(\d{6})\b/)?.[1];
+ if (!code) return false;
+ log('[magic-link] Captured displayed verification code — returning to sign-in');
+ await driver.goto(driver._authUrl).catch(() => {});
+ await sleep(2000);
+ return finishMagicLinkLogin(`code:${code}`);
+ }
+
for (let step = 0; step < 20; step++) {
await sleep(2500);
const url = await driver.currentUrl().catch(() => '');
@@ -2721,7 +2749,11 @@ async function runAuthFlow(driver, account) {
stallCount = 0;
continue;
}
- if (url.includes('/login') && (await isClaudeLoginCodePage())) {
+ if ((url.includes('/login') || url.includes('/magic-link')) && (await isClaudeLoginCodePage())) {
+ if (await finishDisplayedClaudeVerificationCode()) {
+ stallCount = 0;
+ continue;
+ }
log(`[magic-link] Claude login is waiting for an email verification code; polling Gmail once before aborting`);
const magicLink = await pollGmailForMagicLink(account.email, 30_000);
if (await finishMagicLinkLogin(magicLink)) {