⚡Action新增角色权限判断
This commit is contained in:
parent
0257fb294a
commit
09c45c4ba4
@ -1,6 +1,4 @@
|
|||||||
using Infrastructure;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Infrastructure.Model;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.AspNetCore.Mvc.Filters;
|
using Microsoft.AspNetCore.Mvc.Filters;
|
||||||
using ZR.Model.System.Dto;
|
using ZR.Model.System.Dto;
|
||||||
|
|
||||||
@ -17,8 +15,11 @@ namespace ZR.Admin.WebApi.Filters
|
|||||||
/// 权限字符串,例如 system:user:view
|
/// 权限字符串,例如 system:user:view
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Permission { get; set; } = string.Empty;
|
public string Permission { get; set; } = string.Empty;
|
||||||
|
/// <summary>
|
||||||
|
/// 角色字符串,例如 common,admin
|
||||||
|
/// </summary>
|
||||||
|
public string RolePermi { get; set; } = string.Empty;
|
||||||
private bool HasPermi { get; set; }
|
private bool HasPermi { get; set; }
|
||||||
private bool HasRole { get; set; }
|
|
||||||
public ActionPermissionFilter() { }
|
public ActionPermissionFilter() { }
|
||||||
public ActionPermissionFilter(string permission)
|
public ActionPermissionFilter(string permission)
|
||||||
{
|
{
|
||||||
@ -52,7 +53,10 @@ namespace ZR.Admin.WebApi.Filters
|
|||||||
{
|
{
|
||||||
HasPermi = perms.Exists(f => f.ToLower() == Permission.ToLower());
|
HasPermi = perms.Exists(f => f.ToLower() == Permission.ToLower());
|
||||||
}
|
}
|
||||||
|
if (!HasPermi && !string.IsNullOrEmpty(RolePermi))
|
||||||
|
{
|
||||||
|
HasPermi = info.RoleIds.Contains(RolePermi);
|
||||||
|
}
|
||||||
bool isDemoMode = AppSettings.GetAppConfig("DemoMode", false);
|
bool isDemoMode = AppSettings.GetAppConfig("DemoMode", false);
|
||||||
var url = context.HttpContext.Request.Path;
|
var url = context.HttpContext.Request.Path;
|
||||||
//演示公开环境屏蔽权限
|
//演示公开环境屏蔽权限
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user