コード例 #1
0
        /// <summary>
        /// Handles removing Roles tied to Rights when a Role will be deleted.
        /// </summary>
        /// <param name="roleName"></param>
        public static void OnRoleDeleting(string roleName)
        {
            IEnumerable <Right> rightsWithRole = Right.GetRights(roleName);

            if (rightsWithRole.Any())
            {
                foreach (Right right in rightsWithRole)
                {
                    right.RemoveRole(roleName);
                }

                BlogEngine.Core.Providers.BlogService.SaveRights();
            }
        }
コード例 #2
0
        /// <summary>
        /// Handles updating Role name changes, so Role names tied to Rights stay in sync.
        /// </summary>
        /// <param name="oldname">The old Role name.</param>
        /// <param name="newname">The new Role name.</param>
        public static void OnRenamingRole(string oldname, string newname)
        {
            IEnumerable <Right> rightsWithRole = Right.GetRights(oldname);

            if (rightsWithRole.Any())
            {
                foreach (Right right in rightsWithRole)
                {
                    right.RemoveRole(oldname);
                    right.AddRole(newname);
                }

                BlogEngine.Core.Providers.BlogService.SaveRights();
            }
        }
コード例 #3
0
 /// <summary>
 /// Returns an IEnumerable of Rights that belong to the ecurrent user.
 /// </summary>
 /// <returns></returns>
 public static IEnumerable <Right> CurrentUserRights()
 {
     return(Right.GetRights(Security.GetCurrentUserRoles()));
 }