//
//
//
using ERP.Framework.Constants;
using ERP.Framework.Security;
using Microsoft.AspNetCore.Mvc.Filters;
namespace ERP.Framework.Attribute
{
///
/// 接口权限特性
///
[AttributeUsage(AttributeTargets.Method)]
public class PermissionAttribute : ActionFilterAttribute
{
internal string Code { get; set; }
public PermissionAttribute(string code)
{
Code = code;
}
public override void OnActionExecuted(ActionExecutedContext context)
{
var loginUser = LoginHelper.GetLoginUser();
if (loginUser.Permission.Contains(FrameworkConstant.ADMIN_PERMISSION))
{
return;
}
if (!loginUser.Permission.Contains(this.Code))
{
//throw new Exception(AuthI18N.NoPermission);
}
}
}
}