From c3619d9ac59befe83a297bb79f24b7f1d3c6db04 Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 14 Aug 2013 13:38:28 +1000 Subject: [PATCH] Fixes plugin mgr to not resolve types that shouldn't be resolved. Fixes mntp legacy editor to not throw exceptions when initializing because the legacy tree no longer exists. Fixes authentication when an invalid cookie is detected. --- src/Umbraco.Core/PluginManager.cs | 8 +++- .../PropertyEditors/PreValueEditor.cs | 6 +++ .../PropertyEditors/PropertyEditor.cs | 8 ++++ .../PropertyEditors/ValueEditor.cs | 3 ++ src/Umbraco.Web/UmbracoModule.cs | 45 +++++++++++-------- .../MultiNodeTreePicker/MNTP_DataEditor.cs | 21 ++++++++- 6 files changed, 69 insertions(+), 22 deletions(-) diff --git a/src/Umbraco.Core/PluginManager.cs b/src/Umbraco.Core/PluginManager.cs index 031d4f587d..960b0df16a 100644 --- a/src/Umbraco.Core/PluginManager.cs +++ b/src/Umbraco.Core/PluginManager.cs @@ -430,7 +430,9 @@ namespace Umbraco.Core /// internal IEnumerable ResolvePropertyEditors() { - return ResolveTypes(); + //return all proeprty editor types found except for the base property editor type + return ResolveTypes() + .Except(new[] {typeof (PropertyEditor)}); } /// @@ -466,7 +468,9 @@ namespace Umbraco.Core /// internal IEnumerable ResolveDataTypes() { - return ResolveTypes(); + //ensure we ignore types that should not be loaded + return ResolveTypes() + .Except(new[] {Type.GetType("umbraco.presentation.LiveEditing.Modules.ItemEditing.PageElementEditor,umbraco")}); } /// diff --git a/src/Umbraco.Core/PropertyEditors/PreValueEditor.cs b/src/Umbraco.Core/PropertyEditors/PreValueEditor.cs index 4d8697bf90..3bc978177a 100644 --- a/src/Umbraco.Core/PropertyEditors/PreValueEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/PreValueEditor.cs @@ -3,6 +3,12 @@ using Newtonsoft.Json; namespace Umbraco.Core.PropertyEditors { + /// + /// Defines a pre-value editor + /// + /// + /// The Json serialization attributes are required for manifest property editors to work + /// public class PreValueEditor { /// diff --git a/src/Umbraco.Core/PropertyEditors/PropertyEditor.cs b/src/Umbraco.Core/PropertyEditors/PropertyEditor.cs index 82b52e8b38..650c41a613 100644 --- a/src/Umbraco.Core/PropertyEditors/PropertyEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/PropertyEditor.cs @@ -1,9 +1,17 @@ using System; +using System.Collections.Generic; using Newtonsoft.Json; using Umbraco.Core.IO; +using Umbraco.Core.Models; namespace Umbraco.Core.PropertyEditors { + /// + /// Basic definition of a property editor + /// + /// + /// The Json serialization attributes are required for manifest property editors to work + /// public class PropertyEditor { /// diff --git a/src/Umbraco.Core/PropertyEditors/ValueEditor.cs b/src/Umbraco.Core/PropertyEditors/ValueEditor.cs index c0d1aa39ec..0cc3fe60a6 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueEditor.cs @@ -10,6 +10,9 @@ namespace Umbraco.Core.PropertyEditors /// /// Represents the value editor for the property editor during content editing /// + /// + /// The Json serialization attributes are required for manifest property editors to work + /// public class ValueEditor { /// diff --git a/src/Umbraco.Web/UmbracoModule.cs b/src/Umbraco.Web/UmbracoModule.cs index 90b5f978fc..f24c0199ba 100644 --- a/src/Umbraco.Web/UmbracoModule.cs +++ b/src/Umbraco.Web/UmbracoModule.cs @@ -35,6 +35,7 @@ namespace Umbraco.Web /// static void BeginRequest(HttpContextBase httpContext) { + //we need to set the initial url in our ApplicationContext, this is so our keep alive service works and this must //exist on a global context because the keep alive service doesn't run in a web context. //we are NOT going to put a lock on this because locking will slow down the application and we don't really care @@ -170,26 +171,34 @@ namespace Umbraco.Web var ticket = http.GetUmbracoAuthTicket(); if (ticket != null && !ticket.Expired && http.RenewUmbracoAuthTicket()) { - //create the Umbraco user identity - var identity = new UmbracoBackOfficeIdentity(ticket); - - //set the principal object - var principal = new GenericPrincipal(identity, identity.Roles); - - //It is actually not good enough to set this on the current app Context and the thread, it also needs - // to be set explicitly on the HttpContext.Current !! This is a strange web api thing that is actually - // an underlying fault of asp.net not propogating the User correctly. - if (HttpContext.Current != null) + try { - HttpContext.Current.User = principal; - } - app.Context.User = principal; - Thread.CurrentPrincipal = principal; + //create the Umbraco user identity + var identity = new UmbracoBackOfficeIdentity(ticket); - //This is a back office request, we will also set the culture/ui culture - Thread.CurrentThread.CurrentCulture = - Thread.CurrentThread.CurrentUICulture = - new System.Globalization.CultureInfo(identity.Culture); + //set the principal object + var principal = new GenericPrincipal(identity, identity.Roles); + + //It is actually not good enough to set this on the current app Context and the thread, it also needs + // to be set explicitly on the HttpContext.Current !! This is a strange web api thing that is actually + // an underlying fault of asp.net not propogating the User correctly. + if (HttpContext.Current != null) + { + HttpContext.Current.User = principal; + } + app.Context.User = principal; + Thread.CurrentPrincipal = principal; + + //This is a back office request, we will also set the culture/ui culture + Thread.CurrentThread.CurrentCulture = + Thread.CurrentThread.CurrentUICulture = + new System.Globalization.CultureInfo(identity.Culture); + } + catch (FormatException) + { + //this will occur if the cookie data is invalid + http.UmbracoLogout(); + } } } diff --git a/src/umbraco.editorControls/MultiNodeTreePicker/MNTP_DataEditor.cs b/src/umbraco.editorControls/MultiNodeTreePicker/MNTP_DataEditor.cs index b002218bd8..979eb06e80 100644 --- a/src/umbraco.editorControls/MultiNodeTreePicker/MNTP_DataEditor.cs +++ b/src/umbraco.editorControls/MultiNodeTreePicker/MNTP_DataEditor.cs @@ -10,6 +10,7 @@ using System.Xml.Linq; using ClientDependency.Core; using Umbraco.Core; using Umbraco.Core.IO; +using umbraco.BusinessLogic; using umbraco.cms.presentation.Trees; using umbraco.controls.Images; using umbraco.controls.Tree; @@ -45,7 +46,15 @@ namespace umbraco.editorControls.MultiNodeTreePicker //need to add our tree definitions to the collection. //find the content tree to duplicate - var contentTree = TreeDefinitionCollection.Instance.Single(x => string.Equals(x.Tree.Alias, Umbraco.Core.Constants.Applications.Content, StringComparison.OrdinalIgnoreCase)); + var contentTree = TreeDefinitionCollection.Instance.SingleOrDefault(x => string.Equals(x.Tree.Alias, Umbraco.Core.Constants.Applications.Content, StringComparison.OrdinalIgnoreCase)); + //have put this here because the legacy content tree no longer exists as a tree def + if (contentTree == null) + { + contentTree = new TreeDefinition( + typeof (loadContent), + new ApplicationTree(false, true, 0, "content", "content", "Content", ".sprTreeFolder", ".sprTreeFolder_o", "", typeof (loadContent).GetFullNameWithAssembly(), ""), + new Application("Content", "content", "content")); + } var filteredContentTree = new TreeDefinition(typeof(FilteredContentTree), new umbraco.BusinessLogic.ApplicationTree(true, false, 0, contentTree.Tree.ApplicationAlias, @@ -59,7 +68,15 @@ namespace umbraco.editorControls.MultiNodeTreePicker contentTree.App); //find the media tree to duplicate - var mediaTree = TreeDefinitionCollection.Instance.Single(x => string.Equals(x.Tree.Alias, Umbraco.Core.Constants.Applications.Media, StringComparison.OrdinalIgnoreCase)); + var mediaTree = TreeDefinitionCollection.Instance.SingleOrDefault(x => string.Equals(x.Tree.Alias, Umbraco.Core.Constants.Applications.Media, StringComparison.OrdinalIgnoreCase)); + //have put this here because the legacy content tree no longer exists as a tree def + if (mediaTree == null) + { + mediaTree = new TreeDefinition( + typeof(loadMedia), + new ApplicationTree(false, true, 0, "media", "media", "Media", ".sprTreeFolder", ".sprTreeFolder_o", "", typeof(loadMedia).GetFullNameWithAssembly(), ""), + new Application("Media", "media", "media")); + } var filteredMediaTree = new TreeDefinition(typeof(FilteredMediaTree), new umbraco.BusinessLogic.ApplicationTree(true, false, 0, mediaTree.Tree.ApplicationAlias,