mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-08 23:33:16 +08:00
Resolve UDS ACL identity from cookies when sessionStore is empty.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
a283b5cdc6
commit
382264f9d6
1 changed files with 21 additions and 2 deletions
|
|
@ -107,7 +107,26 @@ export async function resolveIdentityFromRequest(req, deps) {
|
|||
} catch {
|
||||
userContext = null
|
||||
}
|
||||
if (!userContext) return null
|
||||
|
||||
const token = parseCookie(cookie, 'PORTALSSOCookie')
|
||||
|| parseCookie(cookie, 'ZTEDPGSSOCookie')
|
||||
const isFallback = empNo === 'administrator'
|
||||
|| !!parseCookie(cookie, 'UDS_FALLBACK_USER')
|
||||
|
||||
// Host restart / session TTL can drop sessionStore while browser cookies remain.
|
||||
// Still authorize ACL from cookies + roles — otherwise sidebar fail-open shows
|
||||
// sessions but page/follow throw "登录后才能访问会话".
|
||||
if (!userContext) {
|
||||
if (!token && !isFallback) return null
|
||||
userContext = {
|
||||
empNo: String(empNo),
|
||||
userId: String(empNo),
|
||||
isAuthenticated: true,
|
||||
authMode: isFallback ? 'fallback-cookie' : 'cookie-acl',
|
||||
token: token || undefined,
|
||||
lastActiveAt: new Date().toISOString(),
|
||||
}
|
||||
}
|
||||
|
||||
// bootstrap / resolve role
|
||||
let role = rolesStore.getRole(empNo)
|
||||
|
|
@ -124,7 +143,7 @@ export async function resolveIdentityFromRequest(req, deps) {
|
|||
role,
|
||||
permissions,
|
||||
userContext,
|
||||
kind: empNo === 'administrator' ? 'fallback' : 'uds',
|
||||
kind: isFallback ? 'fallback' : 'uds',
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue