mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-08 22:20:54 +08:00
Expose resolveIdentityForEmpNo on udsAuth for role-aware cron cwd.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
627e61aa80
commit
cc32a6c6ea
1 changed files with 26 additions and 0 deletions
|
|
@ -1057,6 +1057,32 @@ async function initServices(ctx, config) {
|
|||
canViewAllJobs(identity) {
|
||||
return !!identity?.permissions?.canViewAllSessions
|
||||
},
|
||||
/**
|
||||
* Resolve role + permissions for an empNo (cron tools / fire-time cwd).
|
||||
* Does not touch request cookies — pure lookup from roles store.
|
||||
*/
|
||||
resolveIdentityForEmpNo(empNo) {
|
||||
const id = String(empNo || '').trim()
|
||||
if (!id || id.startsWith('__')) return null
|
||||
const role = _rolesStore?.getRole?.(id) || 'user'
|
||||
const permissions = computePermissions(role)
|
||||
const workspacePath = (() => {
|
||||
try {
|
||||
const row = _userWorkspaces?.get(id)
|
||||
if (row?.path) return row.path
|
||||
return join(resolveWorkspaceRoot(_currentConfig?.workspaceRoot), id)
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
})()
|
||||
return {
|
||||
empNo: id,
|
||||
role,
|
||||
permissions,
|
||||
displayName: id,
|
||||
workspacePath,
|
||||
}
|
||||
},
|
||||
getProvisionedWorkspacePath(empNo) {
|
||||
if (!empNo) return null
|
||||
const row = _userWorkspaces?.get(String(empNo))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue