diff --git a/rbac/check_perm.py b/rbac/check_perm.py index 8d2eb52..3324a06 100644 --- a/rbac/check_perm.py +++ b/rbac/check_perm.py @@ -8,8 +8,8 @@ from appPublic.jsonConfig import getConfig from appPublic.log import debug, exception from appPublic.dictObject import DictObject from appPublic.uniqueID import getID -from ahserver.globalEnv import password_encode from ahserver.auth_api import AuthAPI, user_login +from ahserver.globalEnv import password_encode from ahserver.serverenv import ServerEnv, get_serverenv, set_serverenv 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" db = DBPools() roles = [] - dbname = get_dbname() + dbname = await get_dbname() async with db.sqlorContext(dbname) as sor: recs = await sor.sqlExe(sql, {'userid':userid}) if len(recs) < 1: @@ -111,16 +111,21 @@ async def register_user(sor, ns): await create_user(sor, ns) return id -def get_dbname(): - f = get_serverenv('get_module_dbname') - if f is None: - raise Exception('get_module_dbname() not defined') - dbname = f('rbac') +def load_rbac(): + AuthAPI.checkUserPermission = objcheckperm + env = ServerEnv() + env.get_user_roles = get_user_roles + 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 async def checkUserPassword(request, username, password): db = DBPools() - dbname = get_dbname() + dbname = await get_dbname() async with db.sqlorContext(dbname) as sor: sql = "select * from users where username=${username}$ and 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}$ """ - dbname = get_dbname() + dbname = await get_dbname() db = DBPools() async with db.sqlorContext(dbname) as sor: perms = await sor.R('permission', {'path':path}) diff --git a/wwwroot/user/user.ui b/wwwroot/user/user.ui index fd60ea4..842b715 100644 --- a/wwwroot/user/user.ui +++ b/wwwroot/user/user.ui @@ -4,7 +4,7 @@ "options":{ "css":"clickable", "tip":"用户功能", - "cwidth":12 + "cwidth":6 }, "binds":[ { @@ -23,15 +23,16 @@ ], "subwidgets":[ { - "widgettype":"Icon", + "widgettype":"Svg", "options":{ - "url":"{{entire_url('/imgs/people.png')}}", + "url":"{{entire_url('/bricks/imgs/user.svg')}}", "rate":1.5 } }, { "widgettype":"Text", "options":{ + "cwidth": 4, "text":"{{get_username()}}" } } @@ -46,12 +47,12 @@ { "name":"login", "tip":"点击登录", - "icon":"{{entire_url('/imgs/login.png')}}" + "icon":"{{entire_url('/bricks/imgs/login.svg')}}" }, { "name":"register", "tip":"点击注册", - "icon":"{{entire_url('/imgs/register.png')}}" + "icon":"{{entire_url('/bricks/imgs/register.svg')}}" } ] },