fix: 角色判断改pipeline库+superuser,org_id查询改pipeline库
This commit is contained in:
parent
8bc02590fa
commit
88e8983109
@ -14,10 +14,10 @@ if not uid:
|
||||
action = (params_kw or {}).get('action', 'get')
|
||||
dbname = get_module_dbname('pipeline-sdlc')
|
||||
|
||||
# 查用户 org_id(sage 库)
|
||||
# 查用户 org_id(pipeline 库)
|
||||
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 ''
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user