Пример #1
0
        public override Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next)
        {
            var userId      = context.HttpContext.User.FindFirst(c => c.Type == ClaimTypes.Sid).Value;
            var currentUser = context.HttpContext.Session.Get <User>(userId);

            if (currentUser == null)
            {
                currentUser = userService.GetFullUser(HttpContextCore.Current.User.Identity.Name);
            }
            if (currentUser == null)
            {
                context.Result = new RedirectToRouteResult("Default", new { controller = "System", action = "ManageLogin" });
                base.OnResultExecutionAsync(context, next);
            }

            if (PermissionsCollction.PermissionItemsCollction == null)
            {
                IEnumerable <PermissionItems> permissionItemsList        = permissionItemsService.GetPermissionItemsAll();
                IEnumerable <string>          rolesNameList              = rolesService.GetRolesNamesInUser(currentUser.UserId);
                IEnumerable <string>          permissionItemsInRolesList = permissionItemsService.Merge(permissionItemsService.GetPermissionItemsInRolesByRolesname(rolesNameList));
                var isSuperManage = false;
                if (authorizerHelper.IsSuperAdministrator(currentUser) || authorizerHelper.IsContentAdministrator(currentUser))
                {
                    isSuperManage = true;
                }

                PermissionsCollction.InitCollction(permissionItemsInRolesList, permissionItemsList, isSuperManage);
            }
            return(base.OnResultExecutionAsync(context, next));
        }