Skip to content

Extending Backoffice UI

Dennis Heutinck edited this page Oct 9, 2022 · 1 revision

Customise dashboard permissions

The dashboard is registered with dependency injection, so you can customise the dashboard permissions just like any native Umbraco dashboard. Follow Umbraco's documentation on customising dashboard permissions, but use UrlTracker.Backoffice.UI.UrlTrackerDashboard. You may end up with something similar to this:

public class MyDashboardComposer : IComposer
{
    public void Compose(IUmbracoBuilder builder)
    {
        builder.Dashboards()
            // Remove the default
            .Remove<UrlTrackerDashboard>()
            // Add the overridden one
            .Add<MyCustomUrlTrackerDashboard>();
    }
}

public class MyCustomUrlTrackerDashboard : UrlTrackerDashboard, IDashboard
{
    IAccessRule[] IDashboard.AccessRules { get; } = new IAccessRule[]
    {
        new AccessRule {Type = AccessRuleType.Deny, Value = Constants.Security.WriterGroupAlias},            
        new AccessRule {Type = AccessRuleType.Grant, Value = Constants.Security.AdminGroupAlias},
        new AccessRule {Type = AccessRuleType.Grant, Value = "marketing"}
    };
}
Clone this wiki locally