{"record":{"id":"d54be9dac31463d3","repo":"jackwener/OpenCLI","slug":"boss-redirected-to-login-page","errorCode":null,"errorMessage":"Boss redirected to login page","messagePattern":"Boss redirected to login page","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/boss/auth.js","lineNumber":32,"sourceCode":"  if (!await hasBossSessionCookie(page)) {\n    throw new AuthRequiredError('zhipin.com', 'Boss wt2 / t cookies missing');\n  }\n  await page.goto(BOSS_GEEK_JOBS_URL);\n  await page.wait(3);\n  const probe = await page.evaluate(`\n    (() => {\n      const path = location.pathname || '';\n      if (/\\\\/web\\\\/user\\\\/login|\\\\/login\\\\.html/.test(location.href)) {\n        return { kind: 'auth', detail: 'Boss redirected to login page' };\n      }\n      const userType = /\\\\/web\\\\/geek\\\\//.test(path) ? 'geek' : /\\\\/web\\\\/(boss|recruit|chat\\\\/boss)/.test(path) ? 'recruiter' : '';\n      if (!userType) {\n        return { kind: 'auth', detail: 'Boss path does not look like authenticated geek/recruiter page: ' + path };\n      }\n      return { ok: true, user_type: userType };\n    })()\n  `);\n  if (probe?.kind === 'auth') throw new AuthRequiredError('zhipin.com', probe.detail);\n  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Boss probe: ${JSON.stringify(probe)}`);\n  return { user_type: probe.user_type };\n}\n\nregisterSiteAuthCommands({\n  site: 'boss',\n  domain: 'zhipin.com',\n  loginUrl: 'https://login.zhipin.com/',\n  columns: ['user_type'],\n  quickCheck: hasBossSessionCookie,\n  verify: verifyBossIdentity,\n  poll: async (page) => {\n    if (!await hasBossSessionCookie(page)) {\n      throw new AuthRequiredError('zhipin.com', 'Waiting for Boss wt2 / t cookies');\n    }\n    return verifyBossIdentity(page);\n  },\n});","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/boss/auth.js#L14-L50","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Re-run the boss login command to establish a fresh session at login.zhipin.com","Clear zhipin.com cookies for the profile first, then log in again to avoid stale-cookie conflicts","Check whether another login (new device) revoked the session and log in again","Test the same cookies in a normal browser; if it also redirects, the account needs re-authentication (captcha/SMS)"],"exampleFix":"// before\nawait verifyBossIdentity(page); // AuthRequiredError: redirected to login\n// after\nawait page.context().clearCookies();\nawait runSiteLogin('boss');\nawait verifyBossIdentity(page);","handlingStrategy":"try-catch","validationCode":"// Detect a live redirect to login before running boss commands\nawait page.goto('https://www.zhipin.com/web/geek/jobs');\nif (/\\/web\\/user\\/login|\\/login\\.html/.test(page.url())) {\n  await runInteractiveLogin('boss');\n}","typeGuard":"function isLoginRedirect(url) {\n  return typeof url === 'string' &&\n    /\\/web\\/user\\/login|\\/login\\.html/.test(url);\n}","tryCatchPattern":"try {\n  await bossVerify(page);\n} catch (err) {\n  if (err instanceof AuthRequiredError && err.message.includes('redirected to login')) {\n    await clearZhipinCookies(page);\n    await interactiveLogin('boss');\n    return bossVerify(page);\n  }\n  throw err;\n}","preventionTips":["Clear stale zhipin.com cookies before re-login to avoid zombie sessions","Avoid logging into the same account from multiple devices/environments that invalidate sessions","Complete captcha/SMS verification fully; partial auth leaves cookies that still redirect","Monitor session validity periodically instead of only at command time"],"tags":["authentication","session-expired","redirect","zhipin"],"backgroundTag":"auth-session-expired","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}