jeecgboot/JeecgBoot · warning · Error
token无效
Error message
token无效
What it means
In the Online cgform 'share' feature (a public link view), checkUrlToken() reads a `token` query param from the URL, sets it as the auth token, then calls getUserInfo() to validate. If getUserInfo() returns no userInfo object, the token is treated as invalid/expired and the error is thrown (but caught immediately, so it does not propagate — it returns false). The token is cleared and cache removed in the catch block, causing the share view to show an unauthenticated/failed state.
Source
Thrown at jeecgboot-vue3/src/views/super/online/cgform/share/store/shareStore.ts:41
},
getDataRecord(): Nullable<Recordable> {
return this.dataRecord;
},
},
actions: {
// 检查 url 参数是否携带token
async checkUrlToken(): Promise<boolean> {
const token = new URLSearchParams(window.location.search).get('token');
const flag = token != null && token.length > 0;
if (flag) {
userStore.setToken(token);
// 检查 token 是否有效
try {
const res = await getUserInfo();
if (!res?.userInfo) {
throw new Error('token无效');
} else {
userStore.setUserInfo(res.userInfo)
if (res.sysAllDictItems) {
userStore.setAllDictItems(res.sysAllDictItems);
}
}
return true;
} catch (e) {
userStore.setToken('');
removeCacheByDynKey(TOKEN_KEY)
return false;
}
}
return flag;
},
setCgformRecord(value: Nullable<Recordable>) {
this.cgformRecord = value;View on GitHub (pinned to 96fb33f5ec)
Solutions
- Regenerate or re-issue the share token from the source system and update the link.
- Verify the token's signing key matches the backend's current secret (check application.yml jwt config).
- Check that the backend /sys/user/getUserInfo returns userInfo for that token (test via Postman).
- If the user was deleted/disabled, re-enable or re-share from an active user.
Defensive patterns
Strategy: try-catch
Validate before calling
// Validate token shape before relying on it
const token = new URLSearchParams(window.location.search).get('token');
if (!token || token.split('.').length !== 3) {
showShareError('Invalid or missing token');
return;
} Type guard
const isValidJwtShape = (t: string | null): boolean =>
!!t && t.split('.').length === 3 && token.length > 0; Try / catch
// shareStore.checkUrlToken already catches internally; consume the boolean
const ok = await shareStore.checkUrlToken();
if (!ok) { showShareError('Token expired or invalid'); } Prevention
- Regenerate share tokens before they expire.
- Keep JWT signing keys in sync across deployments.
- Show a clear 'link expired' UI when checkUrlToken returns false.
When it happens
Trigger: Opening a shared online-cgform link whose `?token=...` query param is expired, revoked, malformed, or for a deleted/disabled user. Also when the backend user service is down and getUserInfo() returns a partial/empty response.
Common situations: Shared report/form links that have expired; tokens generated by an older signing key after a key rotation; backend getUserInfo endpoint returning success:false with no userInfo; network/proxy issues causing an empty response that bypasses the axios success check.
Related errors
- token不存在~
- token不存在~
- token不存在~
- useDescription() can only be used inside setup() or function
- useTableContext must be used after createTableContext
AI-assisted analysis of jeecgboot/JeecgBoot@96fb33f5ec (2026-08-14).
Data as JSON: /api/errors/e0cb3ac9981b99ae.
Report an issue: GitHub.