* Sends GUID instead of the numeric ID for SignalR Preview Hub * Add possibility to set cookies as HttpOnly * Set UMB_PREVIEW cookie as HttpOnly * fixup! Add possibility to set cookies as HttpOnly * Refactor ContentFinderByIdPath to more readable * Create ContentFinderByKeyPath reusing logic from ContentFinderByIdPath * Add a comment to DisableFindContentByIdPath setting * Append new content finder * Change ordering of content finders registrations * Refactor with a base class * Update/refactor and add tests regarding ContentFindersByIdentifier * Fix comment * Avoiding breaking change * Make usages use non-obsolete implementation * Fixed todo in config instead of use the one old legacy name even more. Also obsoleted the ContentFinderByIdPath * add `preview` as an allowed backoffice client route --------- Co-authored-by: Sven Geusens <sge@umbraco.dk> Co-authored-by: Bjarke Berg <mail@bergmania.dk> Co-authored-by: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com>
45 lines
1.4 KiB
C#
45 lines
1.4 KiB
C#
using Microsoft.Extensions.Logging;
|
|
using Umbraco.Cms.Core.Web;
|
|
|
|
namespace Umbraco.Cms.Core.Routing;
|
|
|
|
public abstract class ContentFinderByIdentifierPathBase
|
|
{
|
|
private readonly IRequestAccessor _requestAccessor;
|
|
private readonly ILogger<ContentFinderByIdentifierPathBase> _logger;
|
|
|
|
/// <remark>
|
|
/// Used as the log message inside <see cref="LogAndReturnFailure()"/>>.
|
|
/// </remark>
|
|
protected abstract string FailureLogMessageTemplate { get; }
|
|
|
|
protected ContentFinderByIdentifierPathBase(IRequestAccessor requestAccessor, ILogger<ContentFinderByIdentifierPathBase> logger)
|
|
{
|
|
_requestAccessor = requestAccessor;
|
|
_logger = logger;
|
|
}
|
|
|
|
protected void ResolveAndSetCultureOnRequest(IPublishedRequestBuilder frequest)
|
|
{
|
|
var cultureFromQuerystring = _requestAccessor.GetQueryStringValue("culture");
|
|
|
|
// Check if we have a culture in the query string
|
|
if (!string.IsNullOrEmpty(cultureFromQuerystring))
|
|
{
|
|
// We're assuming it will match a culture, if an invalid one is passed in,
|
|
// an exception will throw (there is no TryGetCultureInfo method)
|
|
frequest.SetCulture(cultureFromQuerystring);
|
|
}
|
|
}
|
|
|
|
protected Task<bool> LogAndReturnFailure()
|
|
{
|
|
if (_logger.IsEnabled(LogLevel.Debug))
|
|
{
|
|
_logger.LogDebug(FailureLogMessageTemplate);
|
|
}
|
|
|
|
return Task.FromResult(false);
|
|
}
|
|
}
|