jackwener/OpenCLI · error · AuthRequiredError

Boss redirected to login page

Error message

Boss redirected to login page

What it means

verifyBossIdentity navigates to the zhipin.com geek jobs page and runs an in-page probe; if the probe reports kind 'auth' because location.href matches /web/user/login or /login.html, the library throws AuthRequiredError with detail 'Boss redirected to login page'. The wt2/t cookies may exist but the server rejected them, redirecting to the login flow. It means the session is invalid despite cookie presence.

Source

Thrown at clis/boss/auth.js:32

  if (!await hasBossSessionCookie(page)) {
    throw new AuthRequiredError('zhipin.com', 'Boss wt2 / t cookies missing');
  }
  await page.goto(BOSS_GEEK_JOBS_URL);
  await page.wait(3);
  const probe = await page.evaluate(`
    (() => {
      const path = location.pathname || '';
      if (/\\/web\\/user\\/login|\\/login\\.html/.test(location.href)) {
        return { kind: 'auth', detail: 'Boss redirected to login page' };
      }
      const userType = /\\/web\\/geek\\//.test(path) ? 'geek' : /\\/web\\/(boss|recruit|chat\\/boss)/.test(path) ? 'recruiter' : '';
      if (!userType) {
        return { kind: 'auth', detail: 'Boss path does not look like authenticated geek/recruiter page: ' + path };
      }
      return { ok: true, user_type: userType };
    })()
  `);
  if (probe?.kind === 'auth') throw new AuthRequiredError('zhipin.com', probe.detail);
  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Boss probe: ${JSON.stringify(probe)}`);
  return { user_type: probe.user_type };
}

registerSiteAuthCommands({
  site: 'boss',
  domain: 'zhipin.com',
  loginUrl: 'https://login.zhipin.com/',
  columns: ['user_type'],
  quickCheck: hasBossSessionCookie,
  verify: verifyBossIdentity,
  poll: async (page) => {
    if (!await hasBossSessionCookie(page)) {
      throw new AuthRequiredError('zhipin.com', 'Waiting for Boss wt2 / t cookies');
    }
    return verifyBossIdentity(page);
  },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-run the boss login command to establish a fresh session at login.zhipin.com
  2. Clear zhipin.com cookies for the profile first, then log in again to avoid stale-cookie conflicts
  3. Check whether another login (new device) revoked the session and log in again
  4. Test the same cookies in a normal browser; if it also redirects, the account needs re-authentication (captcha/SMS)

Example fix

// before
await verifyBossIdentity(page); // AuthRequiredError: redirected to login
// after
await page.context().clearCookies();
await runSiteLogin('boss');
await verifyBossIdentity(page);
Defensive patterns

Strategy: try-catch

Validate before calling

// Detect a live redirect to login before running boss commands
await page.goto('https://www.zhipin.com/web/geek/jobs');
if (/\/web\/user\/login|\/login\.html/.test(page.url())) {
  await runInteractiveLogin('boss');
}

Type guard

function isLoginRedirect(url) {
  return typeof url === 'string' &&
    /\/web\/user\/login|\/login\.html/.test(url);
}

Try / catch

try {
  await bossVerify(page);
} catch (err) {
  if (err instanceof AuthRequiredError && err.message.includes('redirected to login')) {
    await clearZhipinCookies(page);
    await interactiveLogin('boss');
    return bossVerify(page);
  }
  throw err;
}

Prevention

When it happens

Trigger: Calling boss auth verify (or poll, which delegates to verifyBossIdentity) when zhipin.com redirects an authenticated-area navigation to a login URL — typically because the session cookie value is stale, revoked, or fails server-side validation.

Common situations: Session expired server-side but old cookies still in profile; login from another device invalidated the session; anti-bot detection forcing re-auth; cookies copied from a different environment/domain that the server won't accept.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/d54be9dac31463d3. Report an issue: GitHub.