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.

This commit is contained in:
Shannon
2013-08-14 13:38:28 +10:00
parent 4a7fbfa3fa
commit c3619d9ac5
6 changed files with 69 additions and 22 deletions

View File

@@ -430,7 +430,9 @@ namespace Umbraco.Core
/// </summary>
internal IEnumerable<Type> ResolvePropertyEditors()
{
return ResolveTypes<PropertyEditor>();
//return all proeprty editor types found except for the base property editor type
return ResolveTypes<PropertyEditor>()
.Except(new[] {typeof (PropertyEditor)});
}
/// <summary>
@@ -466,7 +468,9 @@ namespace Umbraco.Core
/// <returns></returns>
internal IEnumerable<Type> ResolveDataTypes()
{
return ResolveTypes<IDataType>();
//ensure we ignore types that should not be loaded
return ResolveTypes<IDataType>()
.Except(new[] {Type.GetType("umbraco.presentation.LiveEditing.Modules.ItemEditing.PageElementEditor,umbraco")});
}
/// <summary>

View File

@@ -3,6 +3,12 @@ using Newtonsoft.Json;
namespace Umbraco.Core.PropertyEditors
{
/// <summary>
/// Defines a pre-value editor
/// </summary>
/// <remarks>
/// The Json serialization attributes are required for manifest property editors to work
/// </remarks>
public class PreValueEditor
{
/// <summary>

View File

@@ -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
{
/// <summary>
/// Basic definition of a property editor
/// </summary>
/// <remarks>
/// The Json serialization attributes are required for manifest property editors to work
/// </remarks>
public class PropertyEditor
{
/// <summary>

View File

@@ -10,6 +10,9 @@ namespace Umbraco.Core.PropertyEditors
/// <summary>
/// Represents the value editor for the property editor during content editing
/// </summary>
/// <remarks>
/// The Json serialization attributes are required for manifest property editors to work
/// </remarks>
public class ValueEditor
{
/// <summary>

View File

@@ -35,6 +35,7 @@ namespace Umbraco.Web
/// <param name="httpContext"></param>
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();
}
}
}

View File

@@ -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,