Hide Skybrud Redirects dashboard from custom user ...
# help-with-umbraco
d
Hi, having followed the docs (https://docs.umbraco.com/umbraco-cms/extending/dashboards#override-an-umbraco-dashboard) on how to hide the default Umbraco redirects dashboard from certain user groups, does anyone know how to do the same thing for the Skybrud Redirects dashboard? I came across this comment https://github.com/skybrud/Skybrud.Umbraco.Redirects/issues/116#issuecomment-1006699933 but am struggling to understand how to actually implement it.
j
Looks like something like this would do it:
Copy code
csharp
using Skybrud.Umbraco.Redirects.Helpers;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.Dashboards;

namespace Test;

public class SkybrudDashboardAccessOverwrite : IComposer
{
    public void Compose(IUmbracoBuilder builder)
    {
        builder.Services.AddUnique<RedirectsBackOfficeHelper, MyRedirectsBackOfficeHelper>();
    }
}

public class MyRedirectsBackOfficeHelper : RedirectsBackOfficeHelper {
    public MyRedirectsBackOfficeHelper(RedirectsBackOfficeHelperDependencies dependencies) : base(dependencies)
    {
    }

    public override IAccessRule[] GetDashboardAccessRules()
    {
        return new IAccessRule[]
        {
            new AccessRule {Type = AccessRuleType.Deny, Value = Umbraco.Cms.Core.Constants.Security.WriterGroupAlias},
            new AccessRule {Type = AccessRuleType.Grant, Value = Umbraco.Cms.Core.Constants.Security.AdminGroupAlias},
            new AccessRule {Type = AccessRuleType.Grant, Value = "marketing"}
        };
    }
}
d
Brilliant, this works great, thank you! 🙂
a
Notice that it might be good to add
[ComposeAfter(typeof(RedirectsComposer))]
to your composer class. Assemblies are registered alphabetically, so if your assembly name is before
Skybrud...
, it likely wouldn't have worked. IIRC
.AddUnique
doesn't fix that.
Something similar to Jesper's example is also explained in the docs, although it's split into two different pages: https://packages.skybrud.dk/skybrud.umbraco.redirects/docs/v4/configuration/ https://packages.skybrud.dk/skybrud.umbraco.redirects/docs/v4/configuration/dashboard/ Did you come across these? If not, is there anything I can do to make it more obvious that there is a documentation site for the package?
d
Thanks Anders. I'll update to make it a bit more solid, following those examples. I had come across the documentation, which makes sense now in hindsight, but I'm probably unusual in that I'm not a back-end dev so I find this stuff hard to piece together (particular since .NET Core and DI/Composers etc came about). Following the Umbraco docs around dashboards and permissions was easy enough but these ones were a step too far for me personally. As I say though I'm probably not the intended audience so this is not a criticism whatsoever. 🙂
a
No worries. I'm also only asking to see if there is anything I can do better. Ideally it should also be able to configure this via apssettings.json, but I think I struggled finding the right format. Here are some examples from my test site. https://cdn.discordapp.com/attachments/1199766139434188900/1200058954663854090/image.png?ex=65c4ccfe&is=65b257fe&hm=b094b0c251f84d73fe1bc548339900004569bb66540be1ded0cbc4dc81091b1f&
d
☝️ Like it!
21 Views