Try our conversational search powered by Generative AI!

Access attribute for Blocks

Vote:
 

I'm trying to set the Access attribute for a block, so only a specific group is able to create that block (rather than the default "Everyone"). I'm following the info here:

http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-CMS/8/Content/Attributes/

http://world.episerver.com/documentation/Class-library/?documentId=cms/9/CD41BF37

The block is still being created with the default "Everyone" access. Am I missing something?

Sample code:

namespace cms.Models.Blocks
{
    [ContentType(DisplayName = "PageTitleBlock", GUID = "623351a8-55c0-4f9f-af08-18a1ffe9ba0f", Description = "")]

    [Access(Roles = "BlockCreators")]

    public class PageTitleBlock : BlockData
    {
        [UIHint(UIHint.Image)]
        [Display(
            Name = "Image",
            Description = "Background image for banner",
            GroupName = SystemTabNames.Content,
            Order = 1)]
        public virtual ContentReference Image { get; set; }

        [CultureSpecific]
        [Display(
            Name = "Title",
            Description = "Page Title",
            GroupName = SystemTabNames.Content,
            Order = 2)]
        public virtual String Title { get; set; }

        [CultureSpecific]
        [Display(
            Name = "Subtitle",
            Description = "Page subtitle",
            GroupName = SystemTabNames.Content,
            Order = 3)]
        public virtual String Subtitle { get; set; }
    }
}

#139860
Oct 08, 2015 0:55
Vote:
 

Hi,

It looks like everything is setup correctly in your code.

You could try to temporary set similar settings on Page type instead for a Block type and see if the pages are restirected.

You could also check access rights for block in admin mode:  Admin->Content Type -> PageTitleBlock -> Settings -> Access Level

Or maybe there is a problem with roles assigned to user that you are using to test - he has BlockCreators role.

#139864
Oct 08, 2015 9:29
Vote:
 

I've been checking to see if the access rights were applied correctly at the screen you mentioned; just shows "Everyone" for the new block. I also just did a quick test creating a new page type, and had the same results.

I made sure the role exists in the system (in case that made a difference), but got the same results.

#139886
Oct 08, 2015 16:33
Vote:
 

Did you try clicking the "revert to default" in admin mode?

#139902
Oct 09, 2015 9:51
Vote:
 

That was the last thing I tried last night, and it did indeed reset the Access level to the one specified in code. Is that the expected behavior?

#139917
Oct 09, 2015 15:41
Vote:
 

I would expect it to use whatever you had specified in your code, so no. Perhaps if you changed the model at some point, it got "stuck" somehow?

#139919
Oct 09, 2015 15:46
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.