* Run code cleanup * Run dotnet format * Start manual cleanup in Web.Common * Finish up manual cleanup * Fix tests * Fix up InMemoryModelFactory.cs * Inject proper macroRenderer * Update src/Umbraco.Web.Common/Filters/JsonDateTimeFormatAttribute.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Web.Common/Filters/ValidateUmbracoFormRouteStringAttribute.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Fix based on review Co-authored-by: Nikolaj Geisle <niko737@edu.ucl.dk> Co-authored-by: Mole <nikolajlauridsen@protonmail.ch>
24 lines
907 B
C#
24 lines
907 B
C#
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Umbraco.Cms.Core.Security;
|
|
|
|
namespace Umbraco.Cms.Web.Common.Security;
|
|
|
|
public class BackOfficeSecurityAccessor : IBackOfficeSecurityAccessor
|
|
{
|
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="BackOfficeSecurityAccessor" /> class.
|
|
/// </summary>
|
|
public BackOfficeSecurityAccessor(IHttpContextAccessor httpContextAccessor) =>
|
|
_httpContextAccessor = httpContextAccessor;
|
|
|
|
/// <summary>
|
|
/// Gets the current <see cref="IBackOfficeSecurity" /> object.
|
|
/// </summary>
|
|
// RequestServices can be null when testing, even though compiler says it can't
|
|
public IBackOfficeSecurity? BackOfficeSecurity
|
|
=> _httpContextAccessor.HttpContext?.RequestServices?.GetService<IBackOfficeSecurity>();
|
|
}
|