protected override void OnAuthorization(AuthorizationContext filterContext) { if (!FormsAuthService.IsSignedIn()) { filterContext.HttpContext.Response.Write("<script>window.top.location.href='/Account/LogOn';</script>"); filterContext.HttpContext.Response.End(); return; } var controllerName = filterContext.RouteData.Values["controller"].ToString(); var actionName = filterContext.RouteData.Values["action"].ToString(); var powerInfo = _powersTask.Get(controllerName, actionName); if (powerInfo == null) { return; } if (!_adminUserTask.ExistsPower(LogOnUserName, powerInfo.PowerId)) { filterContext.HttpContext.Response.Write("对不起,您没有此权限"); filterContext.HttpContext.Response.End(); return; } }
public AdminUser GetCurrentAdmin() { if (FormsAuthService.IsSignedIn()) { return(_adminUserTask.GetByUserName(FormsAuthService.GetCurrentIdentity().Name)); } return(null); }