Piranha CMS new menu for the manager

  Kiến thức lập trình

I have successfully created a new menu item to the manager. The downside is that those who are not logged in can view the menu item and page. So far I have this C# code within Startup.cs and the method Configure():

Menu.Items["Competitions"].Items.Add(new MenuItem
    InternalId = "CompetitionData",
    Name = "Competition data",
    Route = "~/manager/Competitions/CompetitionData",
    Css = "fas fa-file-excel"               

I know that I need to add the Policy property to the above code, but I don’t know what value I should put in there. I have tried various values but either the code falls over, or it runs and the “public” can view the URL.

First of all I can’t find any documentation about the Policy property, and secondly, I don’t understand the link between roles, claims and policies. I would be grateful if anyone could point me in the right direction.

Thank you very much.

Policies are a standard feature and is basically a named collection of one or more claims. You need to add the policies in your startup code or else the code, like you say, will fail when the code references an unknown policy.

Here’s an example of where the Identity module for Piranha adds it’s custom policies that is used in the manager.


Best regards