后端角色权限新增加管理员判断
This commit is contained in:
parent
ae5e215b7b
commit
3b2c1577ff
@ -13,5 +13,9 @@ namespace Infrastructure
|
||||
/// 管理员权限
|
||||
/// </summary>
|
||||
public static string AdminPerm = "*:*:*";
|
||||
/// <summary>
|
||||
/// 管理员角色
|
||||
/// </summary>
|
||||
public static string AdminRole = "admin";
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,10 +43,15 @@ namespace ZR.Admin.WebApi.Filters
|
||||
if (info != null && info?.UserId > 0)
|
||||
{
|
||||
List<string> perms = info.Permissions;
|
||||
List<string> rolePerms = info.RoleIds;
|
||||
if (perms.Exists(f => f.Equals(GlobalConstant.AdminPerm)))
|
||||
{
|
||||
HasPermi = true;
|
||||
}
|
||||
else if (rolePerms.Exists(f => f.Equals(GlobalConstant.AdminRole)))
|
||||
{
|
||||
HasPermi = true;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(Permission))
|
||||
{
|
||||
HasPermi = perms.Exists(f => f.ToLower() == Permission.ToLower());
|
||||
@ -55,7 +60,7 @@ namespace ZR.Admin.WebApi.Filters
|
||||
bool isDemoMode = ConfigUtils.Instance.GetAppConfig("DemoMode", false);
|
||||
|
||||
//演示公开环境屏蔽权限
|
||||
string[] denyPerms = new string[] { "update", "add", "remove", "add", "edit", "delete", "import", "run", "start", "stop", "clear", "send" ,"export", "upload", "common"};
|
||||
string[] denyPerms = new string[] { "update", "add", "remove", "add", "edit", "delete", "import", "run", "start", "stop", "clear", "send", "export", "upload", "common" };
|
||||
if (isDemoMode && denyPerms.Any(f => Permission.ToLower().Contains(f)))
|
||||
{
|
||||
context.Result = new JsonResult(new { code = ResultCode.FORBIDDEN, msg = "演示模式 , 不允许操作" });
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user