diff --git a/ContentProtector/Components/ActionBlocker.cs b/ContentProtector/Components/ActionBlocker.cs index 6fcb4b9..c397f51 100644 --- a/ContentProtector/Components/ActionBlocker.cs +++ b/ContentProtector/Components/ActionBlocker.cs @@ -41,7 +41,7 @@ private void ContentService_Trashing(IContentService sender,MoveEventArgs("Failed to get Content Protector setting for rollBack action: " + ex.Message); } - + if(rollBack != null) { if(rollBack.nodes.Contains(eventArgs.Entity.Id.ToString()) || rollBack.disableAction) { if(!rollBack.userExceptions.Split(',').Contains(_currentUserId.ToString())) { - eventArgs.CancelOperation(new EventMessage("Action rejected. Contact website admin","You cannot rollBack " + eventArgs.Entity.Name,EventMessageType.Error)); + eventArgs.CancelOperation(new EventMessage("Action rejected. Contact website admin","You cannot rollBack " + eventArgs.Entity.Name,EventMessageType.Error)); } } - } + } } private void ContentService_Unpublishing(IContentService sender,PublishEventArgs eventArgs) { @@ -132,7 +132,7 @@ private void ContentService_Unpublishing(IContentService sender,PublishEventArgs int _currentUserId; using(var contextReference = _context.EnsureUmbracoContext()) { - _currentUserId = contextReference.UmbracoContext.Security.CurrentUser.Id; + _currentUserId = contextReference.UmbracoContext.Security.IsAuthenticated() ? contextReference.UmbracoContext.Security.CurrentUser.Id : Umbraco.Core.Constants.Security.SuperUserId; } try { @@ -163,7 +163,7 @@ private void ContentService_Publishing(IContentService sender,ContentPublishingE int _currentUserId; using(var contextReference = _context.EnsureUmbracoContext()) { - _currentUserId = contextReference.UmbracoContext.Security.CurrentUser.Id; + _currentUserId = contextReference.UmbracoContext.Security.IsAuthenticated() ? contextReference.UmbracoContext.Security.CurrentUser.Id : Umbraco.Core.Constants.Security.SuperUserId; } try { @@ -194,7 +194,7 @@ private void ContentService_Publishing(IContentService sender,ContentPublishingE // int _currentUserId; // using(var contextReference = _context.EnsureUmbracoContext()) { - // _currentUserId = contextReference.UmbracoContext.Security.CurrentUser.Id; + // _currentUserId = contextReference.UmbracoContext.Security.IsAuthenticated() ? contextReference.UmbracoContext.Security.CurrentUser.Id : Umbraco.Core.Constants.Security.SuperUserId; // } // try { @@ -208,17 +208,17 @@ private void ContentService_Publishing(IContentService sender,ContentPublishingE // catch(Exception ex) { // _logger.Error("Failed to get Content Protector setting for copy action: " + ex.Message); // } - + // if(copy != null) { // if(copy.nodes.Contains(eventArgs.Copy.Id.ToString())) { - // if(!copy.userExceptions.Split(',').Contains(_currentUserId.ToString())) { + // if(!copy.userExceptions.Split(',').Contains(_currentUserId.ToString())) { // eventArgs.Cancel = true; // eventArgs.CanCancel = true; // eventArgs.Messages.Add(new EventMessage("Action rejected. Contact website admin","You cannot copy " + eventArgs.Copy.Name,EventMessageType.Error)); // } // } // } - + //} //private void ContentService_Moving(IContentService sender,MoveEventArgs eventArgs) { @@ -226,7 +226,7 @@ private void ContentService_Publishing(IContentService sender,ContentPublishingE // int _currentUserId; // using(var contextReference = _context.EnsureUmbracoContext()) { - // _currentUserId = contextReference.UmbracoContext.Security.CurrentUser.Id; + // _currentUserId = contextReference.UmbracoContext.Security.IsAuthenticated() ? contextReference.UmbracoContext.Security.CurrentUser.Id : Umbraco.Core.Constants.Security.SuperUserId; // } // try { @@ -257,7 +257,7 @@ private void ContentService_Saving(IContentService sender,ContentSavingEventArgs int _currentUserId; using(var contextReference = _context.EnsureUmbracoContext()) { - _currentUserId = contextReference.UmbracoContext.Security.CurrentUser.Id; + _currentUserId = contextReference.UmbracoContext.Security.IsAuthenticated() ? contextReference.UmbracoContext.Security.CurrentUser.Id : Umbraco.Core.Constants.Security.SuperUserId; } try { @@ -280,8 +280,8 @@ private void ContentService_Saving(IContentService sender,ContentSavingEventArgs } } } - } - } + } + } public void Terminate() { }