public static string IsLimits(HttpContext httpContext, string menucode) { if (httpContext.Session["ClientManager"] != null) { WinWarEntity.Users model = (WinWarEntity.Users)httpContext.Session["ClientManager"]; if (model.Menus.Where(m => m.MenuCode == menucode).Count() > 0) { return(""); } } return("nolimits"); }
public override void OnAuthorization(AuthorizationContext filterContext) { base.OnAuthorization(filterContext); if (filterContext.HttpContext.Response.StatusCode == 401) { string source = HttpContext.Current.Request.QueryString["source"]; if (!string.IsNullOrEmpty(source) && source == "md") { filterContext.Result = new RedirectResult("/Home/MDLogin?ReturnUrl=" + HttpContext.Current.Request.Url); } else { filterContext.Result = new RedirectResult("/Home/Login?ReturnUrl=" + HttpContext.Current.Request.Url); } return; } var controller = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName.ToLower(); var action = filterContext.ActionDescriptor.ActionName.ToLower(); var currentUser = (WinWarEntity.Users)filterContext.HttpContext.Session["ClientManager"]; var menu = CommonBusiness.ClientMenus.Where(m => m.Controller.ToLower() == controller && m.View.ToLower() == action).FirstOrDefault(); //需要判断权限 if (menu != null && menu.IsLimit == 1) { WinWarEntity.Users user = (WinWarEntity.Users)filterContext.HttpContext.Session["ClientManager"]; if (user.Menus.Where(m => m.MenuCode == menu.MenuCode).Count() <= 0) { if (filterContext.RequestContext.HttpContext.Request.IsAjaxRequest()) { Dictionary <string, string> result = new Dictionary <string, string>(); result.Add("result", "10001"); filterContext.Result = new JsonResult() { Data = result, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; } { var urlRequest = filterContext.RequestContext.HttpContext.Request; throw new HttpException(403, urlRequest.UrlReferrer != null ? urlRequest.UrlReferrer.AbsoluteUri : urlRequest.Url.AbsoluteUri); //filterContext.RequestContext.HttpContext.Response.Write("<script>alert('您没有权限访问此页面');history.back();</script>"); //filterContext.RequestContext.HttpContext.Response.End(); } } } }
public JsonResult UpdateUserBaseInfo(string entity, string userID) { int result = 0; if (!string.IsNullOrEmpty(userID)) { bool flag = false; JavaScriptSerializer serializer = new JavaScriptSerializer(); WinWarEntity.Users newItem = serializer.Deserialize <WinWarEntity.Users>(entity); WinWarEntity.Users item = OrganizationBusiness.GetUserByUserID(userID); flag = OrganizationBusiness.UpdateUserInfo(userID, newItem.Name, item.Jobs, item.Birthday, item.Age.Value, newItem.DepartID, newItem.Email, newItem.MobilePhone, item.OfficePhone, CurrentUser.AgentID); result = flag ? 1 : 0; } JsonDictionary.Add("result", result); return(new JsonResult { Data = JsonDictionary, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }