fix: 角色判断改pipeline库+superuser,org_id查询改pipeline库

This commit is contained in:
ymq 2026-08-15 20:37:08 +08:00
parent 8bc02590fa
commit 88e8983109
2 changed files with 5 additions and 5 deletions

View File

@ -14,10 +14,10 @@ if not uid:
action = (params_kw or {}).get('action', 'get')
dbname = get_module_dbname('pipeline-sdlc')
# 查用户 org_idsage 库)
# 查用户 org_idpipeline 库)
org_id = ''
try:
async with DBPools().sqlorContext('sage') as sor:
async with DBPools().sqlorContext(dbname) as sor:
urecs = await sor.sqlExe("SELECT orgid FROM users WHERE id=${u}$", {"u": uid})
if urecs:
org_id = getattr(urecs[0], 'orgid', '') or ''

View File

@ -15,15 +15,15 @@ dbname = get_module_dbname('pipeline-sdlc')
# 系统级公众号全局一条org_id 固定为 '0'(业主机构)
SYS_ORG_ID = '0'
# 查用户角色(sage 库),仅 admin 可配置
# 查用户角色(pipeline 库superuser/admin 可配置
is_admin = False
try:
async with DBPools().sqlorContext('sage') as sor:
async with DBPools().sqlorContext(dbname) as sor:
rrecs = await sor.sqlExe(
"SELECT r.name FROM userrole ur JOIN role r ON ur.roleid=r.id WHERE ur.userid=${u}$",
{"u": uid})
roles = [getattr(r, 'name', '') for r in (rrecs or [])]
is_admin = 'admin' in roles
is_admin = ('superuser' in roles) or ('admin' in roles)
except Exception:
pass