Ejemplo n.º 1
0
        private void Initialize(string moduleName, MenuItem item)
        {
            if (item.ReadOnlyProperties != null)
            {
                var roleName = item.ReadOnlyProperties["role"];
                if (!string.IsNullOrEmpty(roleName) && item.Visible)
                {
                    item.Visible = Kooboo.CMS.Sites.Services.ServiceFactory.UserManager.IsInRole(Site.Current
                        , HttpContext.Current.User.Identity.Name
                        , roleName);
                }
                string permissionGroup = item.ReadOnlyProperties["permissionGroup"];
                string permissionName = item.ReadOnlyProperties["permissionName"];
                if (!string.IsNullOrEmpty(permissionName))
                {
                    var permission = new Permission() { AreaName = moduleName, Group = permissionGroup, Name = permissionName };
                    item.Visible = Kooboo.CMS.Sites.Services.ServiceFactory.UserManager.Authorize(Site.Current
                      , HttpContext.Current.User.Identity.Name
                      , permission);
                }
            }

            if (item.Items != null)
            {
                foreach (var chd in item.Items)
                {
                    Initialize(moduleName, chd);
                }
            }
        }
Ejemplo n.º 2
0
 public Permission(Permission p)
 {
     this.AreaName = p.AreaName;
     this.Group = p.Group;
     this.Name = p.Name;
     this.DisplayName = p.DisplayName;
 }
Ejemplo n.º 3
0
        public static bool Authorize(this RequestContext requestContext, Permission permission)
        {
            IPrincipal user = requestContext.HttpContext.User;
            if (!user.Identity.IsAuthenticated)
            {
                return false;
            }
            var site = GetSite(requestContext);

            return Kooboo.CMS.Sites.Services.ServiceFactory.UserManager.Authorize(site, user.Identity.Name, permission);
        }
Ejemplo n.º 4
0
 public CheckPermission(Permission permission)
     : base(permission)
 {
 }
Ejemplo n.º 5
0
Archivo: Role.cs Proyecto: Epitomy/CMS
 //public IEnumerable<string> Users { get; set; }
 //public void AddUser(string userName)
 //{
 //    Users = Users.Concat(new[] { userName });
 //}
 //public void RemoveUser(string userName)
 //{
 //    Users = Users.Where(it => string.Compare(it, userName, true) != 0);
 //}
 //public bool IsUserInRole(string userName)
 //{
 //    return this.Users.Any(it => string.Compare(it, userName, true) == 0);
 //}
 public bool HasPermission(Permission permission)
 {
     return this.Permissions.Any(it => permission == it);
 }
Ejemplo n.º 6
0
 public virtual void AddPermission(Permission permission)
 {
     permissions.Add(permission);
 }