Skip to content

Instantly share code, notes, and snippets.

@TimGeyssens
Last active September 9, 2020 15:00
Show Gist options
  • Save TimGeyssens/5e4e2a0cca5821fb69b17fc49e32e85a to your computer and use it in GitHub Desktop.
Save TimGeyssens/5e4e2a0cca5821fb69b17fc49e32e85a to your computer and use it in GitHub Desktop.
using System.Web.Security;
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.Events;
using Umbraco.Core.Scoping;
using Umbraco.Core.Services;
using Umbraco.Core.Services.Implement;
using System.Linq;
using System;
using Umbraco.Core.Security;
using Umbraco.Web.Editors;
using Umbraco.Web;
using Umbraco.Web.Dashboards;
using Umbraco.Web.PublishedModels;
namespace MySite.Custom
{
[RuntimeLevel(MinLevel = RuntimeLevel.Run)]
public class CustomEventComposer : ComponentComposer<CustomEventComponent>
{ }
public class CustomEventComponent : IComponent
{
public void Initialize()
{
EditorModelEventManager.SendingContentModel += EditorModelEventManager_SendingContentModel;
}
private void EditorModelEventManager_SendingContentModel(System.Web.Http.Filters.HttpActionExecutedContext sender, EditorModelEventArgs<Umbraco.Web.Models.ContentEditing.ContentItemDisplay> e)
{
var identity = (UmbracoBackOfficeIdentity)System.Web.HttpContext.Current.User.Identity;
var currentUSer = Current.Services.UserService.GetByProviderKey(identity.Id);
if (!currentUSer.Groups.Any(x => x.Alias == "admin"))
{
foreach (var variant in e.Model.Variants)
variant.Tabs = variant.Tabs.Where(x => x.Label != "Admin");
}
}
public void Terminate()
{
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment