fixes error with server side validation + data tyep editor, ensures template controller and data type controller inherit from BackOfficeNotificationsController, ensures BackOfficeNotificationsController is attributed with PrefixlessBodyModelValidator

This commit is contained in:
Shannon
2017-01-10 12:29:30 +11:00
parent d66c57cfd0
commit 77d47f0b28
9 changed files with 25 additions and 17 deletions
@@ -178,8 +178,6 @@ function DataTypeEditController($scope, $routeParams, $location, appState, navig
//share state
editorState.set($scope.content);
dataTypeHelper.rebindChangedProperties($scope.content, data);
});
}
@@ -1,3 +1,4 @@
using Umbraco.Web.WebApi;
using Umbraco.Web.WebApi.Filters;
namespace Umbraco.Web.Editors
@@ -8,6 +9,7 @@ namespace Umbraco.Web.Editors
/// currently in the request.
/// </summary>
[AppendCurrentEventMessages]
[PrefixlessBodyModelValidator]
public abstract class BackOfficeNotificationsController : UmbracoAuthorizedJsonController
{
protected BackOfficeNotificationsController()
@@ -106,16 +106,7 @@ namespace Umbraco.Web.Editors
/// Returns the avilable compositions for this content type
/// This has been wrapped in a dto instead of simple parameters to support having multiple parameters in post request body
/// </summary>
/// <param name="contentTypeId"></param>
/// <param name="filterContentTypes">
/// This is normally an empty list but if additional content type aliases are passed in, any content types containing those aliases will be filtered out
/// along with any content types that have matching property types that are included in the filtered content types
/// </param>
/// <param name="filterPropertyTypes">
/// This is normally an empty list but if additional property type aliases are passed in, any content types that have these aliases will be filtered out.
/// This is required because in the case of creating/modifying a content type because new property types being added to it are not yet persisted so cannot
/// be looked up via the db, they need to be passed in.
/// </param>
/// <param name="filter"></param>
/// <returns></returns>
[HttpPost]
public HttpResponseMessage GetAvailableCompositeContentTypes(GetAvailableCompositionsFilter filter)
@@ -33,7 +33,7 @@ namespace Umbraco.Web.Editors
[PluginController("UmbracoApi")]
[UmbracoTreeAuthorize(Constants.Trees.DataTypes, Constants.Trees.DocumentTypes, Constants.Trees.MediaTypes, Constants.Trees.MemberTypes)]
[EnableOverrideAuthorization]
public class DataTypeController : UmbracoAuthorizedJsonController
public class DataTypeController : BackOfficeNotificationsController
{
/// <summary>
/// Gets data type by name
@@ -15,7 +15,7 @@ namespace Umbraco.Web.Editors
{
[PluginController("UmbracoApi")]
[UmbracoTreeAuthorize(Constants.Trees.Templates)]
public class TemplateController : UmbracoAuthorizedJsonController
public class TemplateController : BackOfficeNotificationsController
{
/// <summary>
/// Gets data type by alias
@@ -3,7 +3,18 @@ namespace Umbraco.Web.Models.ContentEditing
public class GetAvailableCompositionsFilter
{
public int ContentTypeId { get; set; }
/// <summary>
/// This is normally an empty list but if additional property type aliases are passed in, any content types that have these aliases will be filtered out.
/// This is required because in the case of creating/modifying a content type because new property types being added to it are not yet persisted so cannot
/// be looked up via the db, they need to be passed in.
/// </summary>
public string[] FilterPropertyTypes { get; set; }
/// <summary>
/// This is normally an empty list but if additional content type aliases are passed in, any content types containing those aliases will be filtered out
/// along with any content types that have matching property types that are included in the filtered content types
/// </summary>
public string[] FilterContentTypes { get; set; }
}
}
@@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace Umbraco.Web.Models.ContentEditing
{
[DataContract(Name = "template", Namespace = "")]
public class TemplateDisplay
public class TemplateDisplay : INotificationModel
{
[DataMember(Name = "id")]
public int Id { get; set; }
@@ -30,5 +30,11 @@ namespace Umbraco.Web.Models.ContentEditing
[DataMember(Name = "masterTemplateAlias")]
public string MasterTemplateAlias { get; set; }
/// <summary>
/// This is used to add custom localized messages/strings to the response for the app to use for localized UI purposes.
/// </summary>
[DataMember(Name = "notifications")]
public List<Notification> Notifications { get; private set; }
}
}
@@ -8,7 +8,7 @@ using Newtonsoft.Json.Serialization;
namespace Umbraco.Web.WebApi
{
/// <summary>
/// Applying this attribute to any webapi controller will ensure that it only contains one json formatter compatible with the angular json vulnerability prevention.
/// Applying this attribute to any webapi controller will ensure that it only contains one json formatter with a camelCase formatter
/// </summary>
public class JsonCamelCaseFormatter : Attribute, IControllerConfiguration
{
@@ -6,7 +6,7 @@ using System.Web.Http.Validation;
namespace Umbraco.Web.WebApi
{
/// <summary>
/// Applying this attribute to any webapi controller will ensure that it only contains one json formatter compatible with the angular json vulnerability prevention.
/// Applying this attribute to any webapi controller will ensure that the <see cref="IBodyModelValidator"/> is of type <see cref="PrefixlessBodyModelValidator"/>
/// </summary>
internal class PrefixlessBodyModelValidatorAttribute : Attribute, IControllerConfiguration
{