Developer forum

Forum » Development » Permissions on ItemManager.Storage.GetById

Permissions on ItemManager.Storage.GetById

Peter Terkildsen
Reply

Hi,

I'm using the following code in order to retrieve an individual item via the API:

            var itemid = Dynamicweb.Base.ChkString(context.Request["itemid"]);
            var itemtype = Dynamicweb.Base.ChkString(context.Request["itemtype"]);

            ItemManager.Initialize();
            var output = ItemManager.Storage.GetById(itemtype, itemid);
            context.Response.Write(JsonConvert.SerializeObject(output));

I can see that this method does not respect permissions set on the individual paragraph that the item belongs to. I know that if I use SelectByParentPageId there is an option to let Dynamicweb check permissions. Is there another way to get individual items and check for permissions?


Replies

 
Nicolai Høeg Pedersen
Reply

Hi Peter

Permissions is set on the paragraph - so load the paragraph and use the BackendUserHasPermissionToEdit() to check for permissions.

Permissions are not on API level - so you have to do the permission check in your implementation.

 
Peter Terkildsen
Reply

Hi again,

I managed to accomplish it using the following:

output = repository.SelectByIds(itemids, query, true);

 

You must be logged in to post in the forum