Node Permision

5 个月 前

                 var _permission =  new PermissionRecord
                    { Name = "Admin area. Manage Medical Roles", SystemName = "ManageMedical", Category = "Medical" },
               _permissionService.InsertPermissionRecord(_permission );

new SiteMapNode()
                {
                    SystemName = "ManageMedical",
                    Title = "Medical",
                    Visible = true,
                    IconClass = "fa-stethoscope",
                    RouteValues = new RouteValueDictionary() { { "area", "Admin" } },
                    ChildNodes = new List<SiteMapNode>()
                    {
                        new SiteMapNode()
                        {
                            SystemName = "ManageMedicalLensesRequest",
                            Title = "Medical Lenses Request",
                            Visible = true,
                            ControllerName = "MedicalLensesRequest",
                            IconClass = "fa-eye",
                            ActionName = "Configure",
                            RouteValues = new RouteValueDictionary() { { "area", "Admin" } }
                        }
                    }
                };


I can not control Access from Access control list. All users can access menu
5 个月 前
Check return of _permissionService.Authorize(_permission) and only display menu option if the user has the permission
5 个月 前
Thank you
Yes.. But why I still see likes in sidebar.
5 个月 前
Looking at the code above - dont know your structure but maybe you should be checking if the permission exists before you create another permission - maybe there is multiple in the database ?
RE: Menu
Did you put the check in the correct place - Checked the operation in Debugger ?
If you still have a problem post the code here
5 个月 前
Thank you


public override void Install()
        {          
            var _permissions = new List<PermissionRecord>()
            {
                new PermissionRecord
                    { Name = "Admin area. Manage Medical Roles", SystemName = "ManageMedical", Category = "Medical" },
                new PermissionRecord
                    { Name = "Admin area. Manage MedicalLenses Request Roles", SystemName = "ManageMedicalLensesRequest", Category = "Medical" }
            };
            foreach (var item in _permissions)
            {
                var _permission = _permissionService.GetPermissionRecordBySystemName(item.SystemName);
                if (_permission == null)
                    _permissionService.InsertPermissionRecord(item);
            }

            base.Install();
        }



        public void ManageSiteMap(SiteMapNode rootNode)
        {
            var _childItem = new SiteMapNode();
            _childItem = new SiteMapNode()
            {
                SystemName = "MedicalLenses",
                Title = "Medical Lenses Request",
                ControllerName = "MedicalLensesRequest",
                ActionName = "Configure",
                Visible = true,
                RouteValues = new RouteValueDictionary() { { "area", "Admin" } }
            };

            var _pluginNode = rootNode.ChildNodes.FirstOrDefault(x => x.SystemName == "Medical");
            if (_pluginNode != null)
                _pluginNode.ChildNodes.Add(_childItem);
            else
            {
                _childItem = new SiteMapNode()
                {
                    SystemName = "ManageMedical",
                    Title = "Medical",
                    Visible = true,
                    IconClass = "fa-stethoscope",
                    RouteValues = new RouteValueDictionary() { { "area", "Admin" } },
                    ChildNodes = new List<SiteMapNode>()
                    {
                        new SiteMapNode()
                        {
                            SystemName = "ManageMedicalLensesRequest",
                            Title = "Medical Lenses Request",
                            Visible = true,
                            ControllerName = "MedicalLensesRequest",
                            IconClass = "fa-eye",
                            ActionName = "Configure",
                            RouteValues = new RouteValueDictionary() { { "area", "Admin" } }
                        }
                    }
                };
                rootNode.ChildNodes.Add(_childItem);
            }
        }


in StandardPermissionProvider class

        public static readonly PermissionRecord ManageMedical = new PermissionRecord { Name = "Admin area. Manage Medical Roles", SystemName = "ManageMedical", Category = "Medical" };
        public static readonly PermissionRecord ManageMedicalLensesRequest = new PermissionRecord { Name = "Admin area. Manage MedicalLenses Request Roles", SystemName = "ManageMedicalLensesRequest", Category = "Medical" };
5 个月 前
Make sure the Install() is running.  If this is an already installed plugin, uninstall it, and then install it again.
5 个月 前
khedr wrote:
But why I still see likes in sidebar.

public static readonly PermissionRecord ManageMedical = new PermissionRecord { Name = "Admin area. Manage Medical Roles", SystemName = "ManageMedical", Category = "Medical" };

public void ManageSiteMap(SiteMapNode rootNode)
{
    // Check if User has permission then display access menu
    if (_permissionService.Authorize(ManageMedical )
    {
        // Display Menu
        var _childItem = new SiteMapNode();
        _childItem = new SiteMapNode()
        ...
    }
}
5 个月 前
Thank you