Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
        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));
        }