Developer forum

Forum » Development » Access to Shops for current user using Security

Access to Shops for current user using Security

Diogo Lino
Reply
Hello,

I'm trying to get a list of the shops the current user backend has access, but using the HasAccess function I don't know what keyword to use on the key parameter, and "Shop" doesn't work as the module name. Any help?

                    var shopsList = (from sh in dataContext.EcomShops
                                     select new {sh.ShopID, sh.ShopName});

                    foreach (var shop in shopsList)
                    {
                        if (Base.HasAccess("Shop", shop.ShopID))
                            shops.Items.Add(new ListItem(shop.ShopName));
                    }

Trying to use a solution like this (http://developer.dynamicweb-cms.com/documentation/for-developers/dynamicweb-custom-modules/integrating-with-security.aspx) but for the list of available Shops.

Other ugly way might be using the database directly, searching where these definitions are stored...

Thanks,
Diogo


Replies

 
Vladimir
Reply

 Hi Diogo!

I think this approach should work:

foreach (var shop in shopsList)
{
    var p = new Dynamicweb.eCommerce.UserPermissions.UserPermission("SHOP", shop.ID);    
    if (p.Granted(Dynamicweb.eCommerce.UserPermissions.UserPermissionRights.Read))
        shops.Items.Add(new ListItem(shop.ShopName));
}

 

Best regards,

Vladimir

 

You must be logged in to post in the forum