修正了 超级管理员 的权限
This commit is contained in:
@@ -61,6 +61,12 @@ def _record_abnormal(account_id, request, attempt_type, detail=''):
|
||||
logger.error(f"记录异常日志失败: {e}")
|
||||
|
||||
|
||||
class _AllPermissions(list):
|
||||
"""拥有 000001 超级管理权限时使用,使任何权限码 in 检查都返回 True"""
|
||||
def __contains__(self, item):
|
||||
return True
|
||||
|
||||
|
||||
def verify_kefu_permission(request, username_from_frontend=None):
|
||||
"""
|
||||
验证客服/管理员身份,并返回该用户的所有权限列表(基于新RBAC表)
|
||||
@@ -129,15 +135,10 @@ def verify_kefu_permission(request, username_from_frontend=None):
|
||||
if current_user.IsSuperuser and '000001' not in permissions:
|
||||
permissions.insert(0, '000001')
|
||||
|
||||
# 拥有 000001(超级管理权限)的用户自动获得所有功能权限码
|
||||
# 拥有 000001(超级管理权限)的用户自动获得所有功能权限
|
||||
# 使用 _AllPermissions 包装,使任何权限码检查都自动通过
|
||||
if '000001' in permissions:
|
||||
_ALL_FEATURE_PERMS = {
|
||||
'bankuai', 'caiwu', 'huiyuancaiwu', 'dingdancaiwu',
|
||||
'qtczcaiwu', 'kaohepeizhi',
|
||||
}
|
||||
for p in _ALL_FEATURE_PERMS:
|
||||
if p not in permissions:
|
||||
permissions.append(p)
|
||||
permissions = _AllPermissions(permissions)
|
||||
|
||||
if not permissions:
|
||||
logger.warning(f"用户 {current_user.Phone} 没有任何权限,请检查角色分配")
|
||||
|
||||
Reference in New Issue
Block a user