public override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); /*if (filterContext.ActionDescriptor.AttributeRouteInfo.GetCustomAttributes(typeof(AllowAnonymous), false).Length != 0) * { * return; * }*/ this.UserContext = SessionContainer.GetUserContext(filterContext.HttpContext); if (this.UserContext == null) { filterContext.Result = new RedirectResult("~/Home/Login"); return; } List <string> list = new List <string>(); int num = 2015; int year = DateTime.Now.Year; do { list.Add(num.ToString()); num++; } while (num <= year); ViewBag.UserContext = this.UserContext; ViewBag.RootOrganization = this.UserContext.RootOrganization; ViewBag.User = this.UserContext.User; ViewBag.Domain = this.UserContext.Domain; ViewBag.YearList = list; }
public override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); if (filterContext.ActionDescriptor.EndpointMetadata != null) { foreach (var obj in filterContext.ActionDescriptor.EndpointMetadata) { if (obj is AllowAnonymousAttribute) { return; } } } this.UserContext = SessionContainer.GetUserContext(filterContext.HttpContext); if (this.UserContext == null) { filterContext.Result = new RedirectResult("~/Home/Login"); return; } List <string> list = new List <string>(); int num = 2015; int year = DateTime.Now.Year; do { list.Add(num.ToString()); num++; } while (num <= year); ViewBag.UserContext = this.UserContext; ViewBag.RootOrganization = this.UserContext.RootOrganization; ViewBag.User = this.UserContext.User; ViewBag.Domain = this.UserContext.Domain; ViewBag.YearList = list; }
public static bool Verify(string key, HttpContext httpContext) { UserContext userContext = SessionContainer.GetUserContext(httpContext); return(userContext.RoleList == null || userContext.RoleList.Count == 0 || userContext.Authorization.Verify(key)); }