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')
|
action = (params_kw or {}).get('action', 'get')
|
||||||
dbname = get_module_dbname('pipeline-sdlc')
|
dbname = get_module_dbname('pipeline-sdlc')
|
||||||
|
|
||||||
# 查用户 org_id(sage 库)
|
# 查用户 org_id(pipeline 库)
|
||||||
org_id = ''
|
org_id = ''
|
||||||
try:
|
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})
|
urecs = await sor.sqlExe("SELECT orgid FROM users WHERE id=${u}$", {"u": uid})
|
||||||
if urecs:
|
if urecs:
|
||||||
org_id = getattr(urecs[0], 'orgid', '') or ''
|
org_id = getattr(urecs[0], 'orgid', '') or ''
|
||||||
|
|||||||
@ -15,15 +15,15 @@ dbname = get_module_dbname('pipeline-sdlc')
|
|||||||
# 系统级公众号:全局一条,org_id 固定为 '0'(业主机构)
|
# 系统级公众号:全局一条,org_id 固定为 '0'(业主机构)
|
||||||
SYS_ORG_ID = '0'
|
SYS_ORG_ID = '0'
|
||||||
|
|
||||||
# 查用户角色(sage 库),仅 admin 可配置
|
# 查用户角色(pipeline 库),superuser/admin 可配置
|
||||||
is_admin = False
|
is_admin = False
|
||||||
try:
|
try:
|
||||||
async with DBPools().sqlorContext('sage') as sor:
|
async with DBPools().sqlorContext(dbname) as sor:
|
||||||
rrecs = await sor.sqlExe(
|
rrecs = await sor.sqlExe(
|
||||||
"SELECT r.name FROM userrole ur JOIN role r ON ur.roleid=r.id WHERE ur.userid=${u}$",
|
"SELECT r.name FROM userrole ur JOIN role r ON ur.roleid=r.id WHERE ur.userid=${u}$",
|
||||||
{"u": uid})
|
{"u": uid})
|
||||||
roles = [getattr(r, 'name', '') for r in (rrecs or [])]
|
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:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user