changing the template check to an enabled check instead.

This commit is contained in:
Claus
2018-02-09 13:19:56 +01:00
parent fb89c3da3c
commit 633d1bb0ae
5 changed files with 32 additions and 8 deletions

View File

@@ -20,11 +20,5 @@ namespace Umbraco.Web.Features
/// Gets the disabled controllers.
/// </summary>
public TypeList<UmbracoApiControllerBase> Controllers { get; private set; }
/// <summary>
/// Specifies if rendering pipeline should ignore HasTemplate check when handling a request.
/// <remarks>This is to allow JSON preview of content with no template set.</remarks>
/// </summary>
public bool AllowRenderWithoutTemplate { get; set; }
}
}

View File

@@ -0,0 +1,22 @@
namespace Umbraco.Web.Features
{
/// <summary>
/// Represents enabled features.
/// </summary>
internal class EnabledFeatures
{
/// <summary>
/// Initializes a new instance of the <see cref="EnabledFeatures"/> class.
/// </summary>
public EnabledFeatures()
{
}
/// <summary>
/// Specifies if rendering pipeline should ignore HasTemplate check when handling a request.
/// <remarks>This is to allow JSON preview of content with no template set.</remarks>
/// </summary>
public bool RenderNoTemplate { get; set; }
}
}

View File

@@ -14,6 +14,7 @@ namespace Umbraco.Web.Features
public UmbracoFeatures()
{
Disabled = new DisabledFeatures();
Enabled = new EnabledFeatures();
}
// note
@@ -28,6 +29,11 @@ namespace Umbraco.Web.Features
/// </summary>
public DisabledFeatures Disabled { get; set; }
/// <summary>
/// Gets the enabled features.
/// </summary>
public EnabledFeatures Enabled { get; set; }
/// <summary>
/// Determines whether a feature is enabled.
/// </summary>
@@ -39,4 +45,4 @@ namespace Umbraco.Web.Features
throw new NotSupportedException("Not a supported feature type.");
}
}
}
}

View File

@@ -395,9 +395,10 @@ namespace Umbraco.Web.Mvc
//here we need to check if there is no hijacked route and no template assigned, if this is the case
//we want to return a blank page, but we'll leave that up to the NoTemplateHandler.
//we also check if we're allowed to render even though there's no template (json render in headless).
if (publishedContentRequest.HasTemplate == false &&
routeDef.HasHijackedRoute == false &&
FeaturesResolver.Current.Features.Disabled.AllowRenderWithoutTemplate == false)
FeaturesResolver.Current.Features.Enabled.RenderNoTemplate == false)
{
publishedContentRequest.UpdateOnMissingTemplate(); // will go 404

View File

@@ -329,6 +329,7 @@
<Compile Include="Editors\ParameterSwapControllerActionSelector.cs" />
<Compile Include="Editors\CodeFileController.cs" />
<Compile Include="Editors\TourController.cs" />
<Compile Include="Features\EnabledFeatures.cs" />
<Compile Include="Models\BackOfficeTourFilter.cs" />
<Compile Include="TourFilterResolver.cs" />
<Compile Include="Editors\UserEditorAuthorizationHelper.cs" />