/// <summary> /// 1. kiem tra phan quyen khi hien len view - object ltsModuleActive /// 2. kiem tra phan quyen khi thuc hien action - object systemActionItem /// </summary> /// <author> linhtx </author> /// <datemodified> 15-Jan-2014 </datemodified> /// <param name="filterContext"></param> protected override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); if (Request.Url != null) { if (User.Identity.IsAuthenticated) { var membershipUser = Membership.GetUser(); if (membershipUser != null) { SystemActionItem = new SystemActionItem(); var providerUserKey = membershipUser.ProviderUserKey; if (providerUserKey != null) { var userId = (Guid)providerUserKey; var path = Request.Url.AbsolutePath.ToLower() + "/"; if (path.Contains(WebConfig.AdminUrl)) { path = path.Replace(WebConfig.AdminUrl, ""); string[] moduleArr = path.Split('/'); if (Mid != moduleArr[0]) { Mid = moduleArr[0]; Title = moduleDa.GetNameByTag(Mid.ToLower()); } var keyCache = "ltsPermissionrole" + userId; // ltsPermissionProductAttribute if (HttpRuntime.Cache[keyCache] == null) { HttpRuntime.Cache[keyCache] = CheckAdmin(); } SystemActionItem.IsAdmin = (bool)HttpRuntime.Cache[keyCache]; if (!SystemActionItem.IsAdmin) { var module = moduleArr[0]; // ProductAttribute var keyCacheModule = "ltsPermission" + userId + module; // ltsPermissionProductAttribute #region user module active if (HttpRuntime.Cache[keyCacheModule] == null) { LtsModuleActive = UserRoleModule(userId, module); if (LtsModuleActive.Any()) { HttpRuntime.Cache[keyCacheModule] = LtsModuleActive; } else { if (!string.IsNullOrEmpty(module)) { filterContext.Result = new RedirectResult("/AccountAdmin"); } } } else { LtsModuleActive = HttpRuntime.Cache[keyCacheModule] as List <ActionActiveItem>; } #endregion } } } } } } }