123456789101112131415161718192021222324252627282930313233343536373839 |
- // <author></author>
- // <date></date>
- // <description></description>
- using ERP.Framework.Constants;
- using ERP.Framework.Security;
- using Microsoft.AspNetCore.Mvc.Filters;
- namespace ERP.Framework.Attribute
- {
- /// <summary>
- /// 接口权限特性
- /// </summary>
- [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);
- }
- }
- }
- }
|