/// <summary>Checks that the current user is authorized to access the current item.</summary> public virtual void AuthoriseRequest() { ContentItem item = _webContext.CurrentPage; if (item == null) return; if (_security.IsAuthorized(item, _webContext.User, Operations.Read)) return; CancelItemEventArgs args = new CancelItemEventArgs(item); if (AuthorizationFailed != null) AuthorizationFailed.Invoke(this, args); if (!args.Cancel) //throw new PermissionDeniedException(item, webContext.User); throw new UnauthorizedAccessException(); }
private void OnItemDeleting(object sender, CancelItemEventArgs e) { if (_recycleBinHandler.CanThrow(e.AffectedItem)) e.FinalAction = _recycleBinHandler.Throw; }
private void securityEnforcer_AuthorizationFailed(object sender, CancelItemEventArgs e) { e.Cancel = true; _authenticationContextService.GetCurrentService().RedirectToLoginPage(); }
/// <summary>Creates an old version of an item. This must be called before the item item is modified.</summary> /// <param name="item">The item to create a old version of.</param> /// <returns>The old version.</returns> public virtual ContentItem SaveVersion(ContentItem item) { CancelItemEventArgs args = new CancelItemEventArgs(item); if (ItemSavingVersion != null) ItemSavingVersion.Invoke(this, args); if (!args.Cancel) { item = args.AffectedItem; ContentItem oldVersion = item.Clone(false); oldVersion.Expires = Utility.CurrentTime().AddSeconds(-1); oldVersion.Updated = Utility.CurrentTime().AddSeconds(-1); oldVersion.Parent = null; oldVersion.TranslationOf = null; oldVersion.VersionOf = item; if (item.Parent != null) oldVersion["ParentID"] = item.Parent.ID; if (item.TranslationOf != null) oldVersion["TranslationOfID"] = item.TranslationOf.ID; _itemRepository.SaveOrUpdate(oldVersion); if (ItemSavedVersion != null) ItemSavedVersion.Invoke(this, new ItemEventArgs(oldVersion)); return oldVersion; } return null; }
private void ItemSavingEventHandler(object sender, CancelItemEventArgs e) { OnItemSaving(e.AffectedItem); }
private void OnPersisterItemSaving(object sender, CancelItemEventArgs e) { if (IsPageCached(e.AffectedItem)) DeleteCachedPage(e.AffectedItem); }