Merge branch 'master' of git.kaiyuancloud.cn:yumoqing/rbac
This commit is contained in:
commit
d03b45962f
@ -8,8 +8,8 @@ from appPublic.jsonConfig import getConfig
|
|||||||
from appPublic.log import debug, exception
|
from appPublic.log import debug, exception
|
||||||
from appPublic.dictObject import DictObject
|
from appPublic.dictObject import DictObject
|
||||||
from appPublic.uniqueID import getID
|
from appPublic.uniqueID import getID
|
||||||
from ahserver.globalEnv import password_encode
|
|
||||||
from ahserver.auth_api import AuthAPI, user_login
|
from ahserver.auth_api import AuthAPI, user_login
|
||||||
|
from ahserver.globalEnv import password_encode
|
||||||
from ahserver.serverenv import ServerEnv, get_serverenv, set_serverenv
|
from ahserver.serverenv import ServerEnv, get_serverenv, set_serverenv
|
||||||
import jwt
|
import jwt
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ async def get_user_roles(userid):
|
|||||||
sql = "select concat(b.orgtypeid, '.', b.name) as name from userrole a, role b where a.userid=${userid}$ and a.roleid = b.id"
|
sql = "select concat(b.orgtypeid, '.', b.name) as name from userrole a, role b where a.userid=${userid}$ and a.roleid = b.id"
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
roles = []
|
roles = []
|
||||||
dbname = get_dbname()
|
dbname = await get_dbname()
|
||||||
async with db.sqlorContext(dbname) as sor:
|
async with db.sqlorContext(dbname) as sor:
|
||||||
recs = await sor.sqlExe(sql, {'userid':userid})
|
recs = await sor.sqlExe(sql, {'userid':userid})
|
||||||
if len(recs) < 1:
|
if len(recs) < 1:
|
||||||
@ -111,16 +111,21 @@ async def register_user(sor, ns):
|
|||||||
await create_user(sor, ns)
|
await create_user(sor, ns)
|
||||||
return id
|
return id
|
||||||
|
|
||||||
def get_dbname():
|
def load_rbac():
|
||||||
f = get_serverenv('get_module_dbname')
|
AuthAPI.checkUserPermission = objcheckperm
|
||||||
if f is None:
|
env = ServerEnv()
|
||||||
raise Exception('get_module_dbname() not defined')
|
env.get_user_roles = get_user_roles
|
||||||
dbname = f('rbac')
|
env.check_user_password = checkUserPassword
|
||||||
|
env.register_user = register_user
|
||||||
|
|
||||||
|
async def get_dbname():
|
||||||
|
rf = RegisterFunction()
|
||||||
|
dbname = await rf.exe('get_module_dbname', 'rbac')
|
||||||
return dbname
|
return dbname
|
||||||
|
|
||||||
async def checkUserPassword(request, username, password):
|
async def checkUserPassword(request, username, password):
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
dbname = get_dbname()
|
dbname = await get_dbname()
|
||||||
async with db.sqlorContext(dbname) as sor:
|
async with db.sqlorContext(dbname) as sor:
|
||||||
sql = "select * from users where username=${username}$ and password=${password}$"
|
sql = "select * from users where username=${username}$ and password=${password}$"
|
||||||
recs = await sor.sqlExe(sql, {'username':username, 'password':password})
|
recs = await sor.sqlExe(sql, {'username':username, 'password':password})
|
||||||
@ -167,7 +172,7 @@ right join userrole c on b.roleid = c.roleid
|
|||||||
where c.userid = ${userid}$
|
where c.userid = ${userid}$
|
||||||
"""
|
"""
|
||||||
|
|
||||||
dbname = get_dbname()
|
dbname = await get_dbname()
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
async with db.sqlorContext(dbname) as sor:
|
async with db.sqlorContext(dbname) as sor:
|
||||||
perms = await sor.R('permission', {'path':path})
|
perms = await sor.R('permission', {'path':path})
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"options":{
|
"options":{
|
||||||
"css":"clickable",
|
"css":"clickable",
|
||||||
"tip":"用户功能",
|
"tip":"用户功能",
|
||||||
"cwidth":12
|
"cwidth":6
|
||||||
},
|
},
|
||||||
"binds":[
|
"binds":[
|
||||||
{
|
{
|
||||||
@ -23,15 +23,16 @@
|
|||||||
],
|
],
|
||||||
"subwidgets":[
|
"subwidgets":[
|
||||||
{
|
{
|
||||||
"widgettype":"Icon",
|
"widgettype":"Svg",
|
||||||
"options":{
|
"options":{
|
||||||
"url":"{{entire_url('/imgs/people.png')}}",
|
"url":"{{entire_url('/bricks/imgs/user.svg')}}",
|
||||||
"rate":1.5
|
"rate":1.5
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"widgettype":"Text",
|
"widgettype":"Text",
|
||||||
"options":{
|
"options":{
|
||||||
|
"cwidth": 4,
|
||||||
"text":"{{get_username()}}"
|
"text":"{{get_username()}}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -46,12 +47,12 @@
|
|||||||
{
|
{
|
||||||
"name":"login",
|
"name":"login",
|
||||||
"tip":"点击登录",
|
"tip":"点击登录",
|
||||||
"icon":"{{entire_url('/imgs/login.png')}}"
|
"icon":"{{entire_url('/bricks/imgs/login.svg')}}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name":"register",
|
"name":"register",
|
||||||
"tip":"点击注册",
|
"tip":"点击注册",
|
||||||
"icon":"{{entire_url('/imgs/register.png')}}"
|
"icon":"{{entire_url('/bricks/imgs/register.svg')}}"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user