2
votes

I need a way to add a menu through the kendo ui.. but the menu needs to be able to only show certain menu items for certain users... ie admin staff should see all menus, while other staff can only see a sub set of those menus... how can I use the authorise attribute to achieve this? any code samples or links would be very helpful

Thanks

VB

2

2 Answers

2
votes

Kendo UI supports this out of the box. Just add the Authorize attribute to your actions and use the Kendo server side wrapper:

@(Html.Kendo().Menu()
    .Name("menu")
    .Items(items =>
    {
        items.Add()
            .Text("Home")
            .Action("Index", "Home");
     })
)

http://www.kendoui.com/forums/ui/menu/binding-to-sitemap-with-security-trimming-on-roles.aspx

http://docs.kendoui.com/api/wrappers/aspnet-mvc/Kendo.Mvc.UI.Fluent/MenuBuilder

1
votes

As MVC is convention based you need to be sure you prevent the controller access via the url On top of just hiding the menus

You’ll need to set up a custom provider so you can work with the roles easier then you’ll need to put the menu into a partial view that builds the menu dynamically.

I dug around and found a site that explains it nicely I think :

Custom provider: http://techbrij.com/custom-roleprovider-authorization-asp-net-mvc

role based menu: http://techbrij.com/role-based-menu-asp-net-mvc