jackwener/OpenCLI · error · AuthRequiredError
Xiaoe admin page showed login UI — anonymous session
Error message
Xiaoe admin page showed login UI — anonymous session
What it means
The in-page probe script checks DOM markers of the login screen (login form elements or absence of any user-name/nickname element). If isLoginPage is true — the page rendered a login UI rather than the account page — the session is treated as anonymous and AuthRequiredError is thrown.
Source
Thrown at clis/xiaoe/auth.js:33
const finalUrl = await page.evaluate(`location.href`);
if (/login|signin|#\/wx$/.test(String(finalUrl || ''))) {
throw new AuthRequiredError('xiaoe-tech.com', `Xiaoe admin page redirected to login: ${finalUrl}`);
}
const cookies = await page.getCookies({ url: 'https://admin.xiaoe-tech.com' });
const xiaoeId = cookies.find(c => c.name === 'XIAOEID')?.value || '';
const unionId = cookies.find(c => c.name === 'unionid')?.value || '';
const probe = await page.evaluate(`
(() => {
const bodyText = document.body?.innerText || '';
if (/微信扫码登录|手机号登录|登录小鹅通/.test(bodyText)) {
return { isLoginPage: true };
}
const nick = document.querySelector('.user-name, .nickname, [class*="userName"], [class*="user-info"]')?.innerText?.trim() || '';
return { isLoginPage: false, domNick: nick };
})()
`);
if (probe.isLoginPage) {
throw new AuthRequiredError('xiaoe-tech.com', 'Xiaoe admin page showed login UI — anonymous session');
}
const userId = xiaoeId || unionId;
if (!userId) {
throw new CommandExecutionError('Xiaoe admin page rendered but no user_id cookie extractable — stale session');
}
return { user_id: String(userId), nickname: String(probe.domNick || '') };
}
registerSiteAuthCommands({
site: 'xiaoe',
domain: 'xiaoe-tech.com',
loginUrl: 'https://admin.xiaoe-tech.com/',
columns: ['user_id', 'nickname'],
quickCheck: hasXiaoeAdminCookie,
verify: verifyXiaoeIdentity,
poll: async (page) => {
if (!await hasXiaoeAdminCookie(page)) {
throw new AuthRequiredError('xiaoe-tech.com', 'Waiting for Xiaoe XIAOEID/b_user_token cookie');View on GitHub (pinned to 49907e53dc)
Solutions
- Log in again via the xiaoe login flow to establish a valid session.
- Increase the wait/settle time after page.goto in case the SPA has not rendered the user info yet.
- Check whether Xiaoe updated admin markup; update the probe selectors (.user-name, .nickname, etc.) if so.
- Confirm in a real browser that muti_index shows the account page with the same cookies.
Example fix
// before
await page.wait(3);
// after
await page.goto('https://admin.xiaoe-tech.com/t/account/muti_index', { settleMs: 8000 }); // let SPA fully render before probing Defensive patterns
Strategy: validation
Validate before calling
const probe = await page.evaluate(`(() => ({ isLoginPage: !!document.querySelector('.login, [class*="login"]') }))()`);
if (probe.isLoginPage) throw new Error('login UI rendered — re-authenticate'); Type guard
function isAuthenticatedDom(probe) {
return probe && probe.isLoginPage === false;
} Try / catch
try {
await verifyXiaoeIdentity(page);
} catch (e) {
if (e instanceof AuthRequiredError) {
await page.wait(5); // allow SPA to finish rendering, then retry once
await verifyXiaoeIdentity(page);
} else throw e;
} Prevention
- Allow generous settle time after navigation so the SPA renders user info before probing.
- Re-auth on any login-UI detection instead of parsing further.
- Watch for Xiaoe admin markup changes and update selectors.
When it happens
Trigger: The admin page at /t/account/muti_index renders but the injected probe finds login-page DOM (e.g. .login selectors) and no .user-name/.nickname/[class*="userName"]/[class*="user-info"] element.
Common situations: Xiaoe changed their admin DOM/class names so the authenticated page no longer matches the user-info selectors; SPA client-side redirect to a login view without changing the URL; partial render raced by the 3s wait.
Related errors
- Xiaoe XIAOEID/b_user_token cookie missing — anonymous
- Xiaoe admin page redirected to login: ${finalUrl}
- Xiaoe admin page rendered but no user_id cookie extractable
- Waiting for Xiaoe XIAOEID/b_user_token cookie
- 请先在共享 Chrome 完成 1688 登录/验证,再重试(${action})
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/06a0bdc58f2caf66.
Report an issue: GitHub.