后端角色权限新增加管理员判断
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());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user