Merge remote-tracking branch 'origin/netcore/bugfix/linux-fix-test' into netcore/feature/azure-yaml-pipeline
This commit is contained in:
@@ -5,24 +5,25 @@ using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Models.ContentEditing;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Security;
|
||||
|
||||
namespace Umbraco.Web.ContentApps
|
||||
{
|
||||
public class ContentAppFactoryCollection : BuilderCollectionBase<IContentAppFactory>
|
||||
{
|
||||
private readonly ILogger<ContentAppFactoryCollection> _logger;
|
||||
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
|
||||
private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor;
|
||||
|
||||
public ContentAppFactoryCollection(IEnumerable<IContentAppFactory> items, ILogger<ContentAppFactoryCollection> logger, IUmbracoContextAccessor umbracoContextAccessor)
|
||||
public ContentAppFactoryCollection(IEnumerable<IContentAppFactory> items, ILogger<ContentAppFactoryCollection> logger, IBackOfficeSecurityAccessor backOfficeSecurityAccessor)
|
||||
: base(items)
|
||||
{
|
||||
_logger = logger;
|
||||
_umbracoContextAccessor = umbracoContextAccessor;
|
||||
_backOfficeSecurityAccessor = backOfficeSecurityAccessor;
|
||||
}
|
||||
|
||||
private IEnumerable<IReadOnlyUserGroup> GetCurrentUserGroups()
|
||||
{
|
||||
var currentUser = _umbracoContextAccessor.UmbracoContext?.Security?.CurrentUser;
|
||||
var currentUser = _backOfficeSecurityAccessor?.BackOfficeSecurity?.CurrentUser;
|
||||
return currentUser == null
|
||||
? Enumerable.Empty<IReadOnlyUserGroup>()
|
||||
: currentUser.Groups;
|
||||
|
||||
@@ -9,6 +9,7 @@ using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Manifest;
|
||||
using Umbraco.Core.Models.ContentEditing;
|
||||
using Umbraco.Core.Models.Identity;
|
||||
using Umbraco.Core.Security;
|
||||
|
||||
namespace Umbraco.Web.ContentApps
|
||||
{
|
||||
@@ -21,8 +22,8 @@ namespace Umbraco.Web.ContentApps
|
||||
{
|
||||
// get the logger factory just-in-time - see note below for manifest parser
|
||||
var loggerFactory = factory.GetRequiredService<ILoggerFactory>();
|
||||
var umbracoContextAccessor = factory.GetRequiredService<IUmbracoContextAccessor>();
|
||||
return new ContentAppFactoryCollection(CreateItems(factory), loggerFactory.CreateLogger<ContentAppFactoryCollection>(), umbracoContextAccessor);
|
||||
var backOfficeSecurityAccessor = factory.GetRequiredService<IBackOfficeSecurityAccessor>();
|
||||
return new ContentAppFactoryCollection(CreateItems(factory), loggerFactory.CreateLogger<ContentAppFactoryCollection>(), backOfficeSecurityAccessor);
|
||||
}
|
||||
|
||||
protected override IEnumerable<IContentAppFactory> CreateItems(IServiceProvider factory)
|
||||
|
||||
@@ -15,11 +15,6 @@ namespace Umbraco.Web
|
||||
/// </summary>
|
||||
DateTime ObjectCreated { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the BackofficeSecurity class
|
||||
/// </summary>
|
||||
IBackOfficeSecurity Security { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the uri that is handled by ASP.NET after server-side rewriting took place.
|
||||
/// </summary>
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Text.RegularExpressions;
|
||||
using Examine;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
@@ -16,19 +17,19 @@ namespace Umbraco.Examine
|
||||
{
|
||||
private readonly IExamineManager _examineManager;
|
||||
private readonly ILocalizationService _languageService;
|
||||
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
|
||||
private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor;
|
||||
private readonly IEntityService _entityService;
|
||||
private readonly IUmbracoTreeSearcherFields _treeSearcherFields;
|
||||
|
||||
public BackOfficeExamineSearcher(IExamineManager examineManager,
|
||||
ILocalizationService languageService,
|
||||
IUmbracoContextAccessor umbracoContextAccessor,
|
||||
IBackOfficeSecurityAccessor backOfficeSecurityAccessor,
|
||||
IEntityService entityService,
|
||||
IUmbracoTreeSearcherFields treeSearcherFields)
|
||||
{
|
||||
_examineManager = examineManager;
|
||||
_languageService = languageService;
|
||||
_umbracoContextAccessor = umbracoContextAccessor;
|
||||
_backOfficeSecurityAccessor = backOfficeSecurityAccessor;
|
||||
_entityService = entityService;
|
||||
_treeSearcherFields = treeSearcherFields;
|
||||
}
|
||||
@@ -47,7 +48,7 @@ namespace Umbraco.Examine
|
||||
query = "\"" + g.ToString() + "\"";
|
||||
}
|
||||
|
||||
var currentUser = _umbracoContextAccessor.UmbracoContext?.Security?.CurrentUser;
|
||||
var currentUser = _backOfficeSecurityAccessor?.BackOfficeSecurity?.CurrentUser;
|
||||
|
||||
switch (entityType)
|
||||
{
|
||||
|
||||
@@ -10,6 +10,7 @@ using Umbraco.Core.Configuration.Models;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Entities;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Services.Implement;
|
||||
using Umbraco.Web.Actions;
|
||||
@@ -183,7 +184,7 @@ namespace Umbraco.Web.Compose
|
||||
/// </summary>
|
||||
public sealed class Notifier
|
||||
{
|
||||
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
|
||||
private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor;
|
||||
private readonly IRequestAccessor _requestAccessor;
|
||||
private readonly INotificationService _notificationService;
|
||||
private readonly IUserService _userService;
|
||||
@@ -194,15 +195,15 @@ namespace Umbraco.Web.Compose
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="umbracoContextAccessor"></param>
|
||||
/// <param name="backOfficeSecurityAccessor"></param>
|
||||
/// <param name="requestAccessor"></param>
|
||||
/// <param name="notificationService"></param>
|
||||
/// <param name="userService"></param>
|
||||
/// <param name="textService"></param>
|
||||
/// <param name="globalSettings"></param>
|
||||
/// <param name="contentConfig"></param>
|
||||
/// <param name="logger"></param>
|
||||
public Notifier(
|
||||
IUmbracoContextAccessor umbracoContextAccessor,
|
||||
IBackOfficeSecurityAccessor backOfficeSecurityAccessor,
|
||||
IRequestAccessor requestAccessor,
|
||||
INotificationService notificationService,
|
||||
IUserService userService,
|
||||
@@ -210,7 +211,7 @@ namespace Umbraco.Web.Compose
|
||||
IOptions<GlobalSettings> globalSettings,
|
||||
ILogger<Notifier> logger)
|
||||
{
|
||||
_umbracoContextAccessor = umbracoContextAccessor;
|
||||
_backOfficeSecurityAccessor = backOfficeSecurityAccessor;
|
||||
_requestAccessor = requestAccessor;
|
||||
_notificationService = notificationService;
|
||||
_userService = userService;
|
||||
@@ -221,7 +222,7 @@ namespace Umbraco.Web.Compose
|
||||
|
||||
public void Notify(IAction action, params IContent[] entities)
|
||||
{
|
||||
var user = _umbracoContextAccessor.UmbracoContext?.Security?.CurrentUser;
|
||||
var user = _backOfficeSecurityAccessor?.BackOfficeSecurity?.CurrentUser;
|
||||
|
||||
//if there is no current user, then use the admin
|
||||
if (user == null)
|
||||
|
||||
@@ -9,6 +9,7 @@ using Umbraco.Core.Media;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Editors;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Web.Templates;
|
||||
@@ -28,7 +29,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
Group = Constants.PropertyEditors.Groups.RichContent)]
|
||||
public class GridPropertyEditor : DataEditor
|
||||
{
|
||||
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
|
||||
private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor;
|
||||
private readonly IIOHelper _ioHelper;
|
||||
private readonly HtmlImageSourceParser _imageSourceParser;
|
||||
private readonly RichTextEditorPastedImages _pastedImages;
|
||||
@@ -37,7 +38,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
|
||||
public GridPropertyEditor(
|
||||
ILoggerFactory loggerFactory,
|
||||
IUmbracoContextAccessor umbracoContextAccessor,
|
||||
IBackOfficeSecurityAccessor backOfficeSecurityAccessor,
|
||||
IDataTypeService dataTypeService,
|
||||
ILocalizationService localizationService,
|
||||
ILocalizedTextService localizedTextService,
|
||||
@@ -49,7 +50,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
IImageUrlGenerator imageUrlGenerator)
|
||||
: base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper)
|
||||
{
|
||||
_umbracoContextAccessor = umbracoContextAccessor;
|
||||
_backOfficeSecurityAccessor = backOfficeSecurityAccessor;
|
||||
_ioHelper = ioHelper;
|
||||
_imageSourceParser = imageSourceParser;
|
||||
_pastedImages = pastedImages;
|
||||
@@ -63,13 +64,13 @@ namespace Umbraco.Web.PropertyEditors
|
||||
/// Overridden to ensure that the value is validated
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected override IDataValueEditor CreateValueEditor() => new GridPropertyValueEditor(Attribute, _umbracoContextAccessor, DataTypeService, LocalizationService, LocalizedTextService, _imageSourceParser, _pastedImages, _localLinkParser, ShortStringHelper, _imageUrlGenerator);
|
||||
protected override IDataValueEditor CreateValueEditor() => new GridPropertyValueEditor(Attribute, _backOfficeSecurityAccessor, DataTypeService, LocalizationService, LocalizedTextService, _imageSourceParser, _pastedImages, _localLinkParser, ShortStringHelper, _imageUrlGenerator);
|
||||
|
||||
protected override IConfigurationEditor CreateConfigurationEditor() => new GridConfigurationEditor(_ioHelper);
|
||||
|
||||
internal class GridPropertyValueEditor : DataValueEditor, IDataValueReference
|
||||
{
|
||||
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
|
||||
private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor;
|
||||
private readonly HtmlImageSourceParser _imageSourceParser;
|
||||
private readonly RichTextEditorPastedImages _pastedImages;
|
||||
private readonly RichTextPropertyEditor.RichTextPropertyValueEditor _richTextPropertyValueEditor;
|
||||
@@ -78,7 +79,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
|
||||
public GridPropertyValueEditor(
|
||||
DataEditorAttribute attribute,
|
||||
IUmbracoContextAccessor umbracoContextAccessor,
|
||||
IBackOfficeSecurityAccessor backOfficeSecurityAccessor,
|
||||
IDataTypeService dataTypeService,
|
||||
ILocalizationService localizationService,
|
||||
ILocalizedTextService localizedTextService,
|
||||
@@ -89,10 +90,10 @@ namespace Umbraco.Web.PropertyEditors
|
||||
IImageUrlGenerator imageUrlGenerator)
|
||||
: base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute)
|
||||
{
|
||||
_umbracoContextAccessor = umbracoContextAccessor;
|
||||
_backOfficeSecurityAccessor = backOfficeSecurityAccessor;
|
||||
_imageSourceParser = imageSourceParser;
|
||||
_pastedImages = pastedImages;
|
||||
_richTextPropertyValueEditor = new RichTextPropertyEditor.RichTextPropertyValueEditor(attribute, umbracoContextAccessor, dataTypeService, localizationService, localizedTextService, shortStringHelper, imageSourceParser, localLinkParser, pastedImages, imageUrlGenerator);
|
||||
_richTextPropertyValueEditor = new RichTextPropertyEditor.RichTextPropertyValueEditor(attribute, backOfficeSecurityAccessor, dataTypeService, localizationService, localizedTextService, shortStringHelper, imageSourceParser, localLinkParser, pastedImages, imageUrlGenerator);
|
||||
_mediaPickerPropertyValueEditor = new MediaPickerPropertyEditor.MediaPickerPropertyValueEditor(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute);
|
||||
_imageUrlGenerator = imageUrlGenerator;
|
||||
}
|
||||
@@ -121,7 +122,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
|
||||
var grid = DeserializeGridValue(rawJson, out var rtes, out _);
|
||||
|
||||
var userId = _umbracoContextAccessor.UmbracoContext?.Security?.CurrentUser?.Id ?? Constants.Security.SuperUserId;
|
||||
var userId = _backOfficeSecurityAccessor?.BackOfficeSecurity?.CurrentUser?.Id ?? Constants.Security.SuperUserId;
|
||||
|
||||
// Process the rte values
|
||||
foreach (var rte in rtes)
|
||||
|
||||
@@ -7,6 +7,7 @@ using Umbraco.Core.Media;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Editors;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Examine;
|
||||
@@ -28,7 +29,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
Icon = "icon-browser-window")]
|
||||
public class RichTextPropertyEditor : DataEditor
|
||||
{
|
||||
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
|
||||
private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor;
|
||||
private readonly HtmlImageSourceParser _imageSourceParser;
|
||||
private readonly HtmlLocalLinkParser _localLinkParser;
|
||||
private readonly RichTextEditorPastedImages _pastedImages;
|
||||
@@ -40,7 +41,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
/// </summary>
|
||||
public RichTextPropertyEditor(
|
||||
ILoggerFactory loggerFactory,
|
||||
IUmbracoContextAccessor umbracoContextAccessor,
|
||||
IBackOfficeSecurityAccessor backOfficeSecurityAccessor,
|
||||
IDataTypeService dataTypeService,
|
||||
ILocalizationService localizationService,
|
||||
HtmlImageSourceParser imageSourceParser,
|
||||
@@ -52,7 +53,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
IImageUrlGenerator imageUrlGenerator)
|
||||
: base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper)
|
||||
{
|
||||
_umbracoContextAccessor = umbracoContextAccessor;
|
||||
_backOfficeSecurityAccessor = backOfficeSecurityAccessor;
|
||||
_imageSourceParser = imageSourceParser;
|
||||
_localLinkParser = localLinkParser;
|
||||
_pastedImages = pastedImages;
|
||||
@@ -64,7 +65,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
/// Create a custom value editor
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected override IDataValueEditor CreateValueEditor() => new RichTextPropertyValueEditor(Attribute, _umbracoContextAccessor, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, _imageSourceParser, _localLinkParser, _pastedImages, _imageUrlGenerator);
|
||||
protected override IDataValueEditor CreateValueEditor() => new RichTextPropertyValueEditor(Attribute, _backOfficeSecurityAccessor, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, _imageSourceParser, _localLinkParser, _pastedImages, _imageUrlGenerator);
|
||||
|
||||
protected override IConfigurationEditor CreateConfigurationEditor() => new RichTextConfigurationEditor(_ioHelper);
|
||||
|
||||
@@ -75,7 +76,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
/// </summary>
|
||||
internal class RichTextPropertyValueEditor : DataValueEditor, IDataValueReference
|
||||
{
|
||||
private IUmbracoContextAccessor _umbracoContextAccessor;
|
||||
private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor;
|
||||
private readonly HtmlImageSourceParser _imageSourceParser;
|
||||
private readonly HtmlLocalLinkParser _localLinkParser;
|
||||
private readonly RichTextEditorPastedImages _pastedImages;
|
||||
@@ -83,7 +84,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
|
||||
public RichTextPropertyValueEditor(
|
||||
DataEditorAttribute attribute,
|
||||
IUmbracoContextAccessor umbracoContextAccessor,
|
||||
IBackOfficeSecurityAccessor backOfficeSecurityAccessor,
|
||||
IDataTypeService dataTypeService,
|
||||
ILocalizationService localizationService,
|
||||
ILocalizedTextService localizedTextService,
|
||||
@@ -94,7 +95,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
IImageUrlGenerator imageUrlGenerator)
|
||||
: base(dataTypeService, localizationService,localizedTextService, shortStringHelper, attribute)
|
||||
{
|
||||
_umbracoContextAccessor = umbracoContextAccessor;
|
||||
_backOfficeSecurityAccessor = backOfficeSecurityAccessor;
|
||||
_imageSourceParser = imageSourceParser;
|
||||
_localLinkParser = localLinkParser;
|
||||
_pastedImages = pastedImages;
|
||||
@@ -146,7 +147,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
if (editorValue.Value == null)
|
||||
return null;
|
||||
|
||||
var userId = _umbracoContextAccessor.UmbracoContext?.Security?.CurrentUser?.Id ?? Constants.Security.SuperUserId;
|
||||
var userId = _backOfficeSecurityAccessor?.BackOfficeSecurity?.CurrentUser?.Id ?? Constants.Security.SuperUserId;
|
||||
|
||||
var config = editorValue.DataTypeConfiguration as RichTextConfiguration;
|
||||
var mediaParent = config?.MediaParentId;
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.HostedServices
|
||||
public class TempFileCleanupTests
|
||||
{
|
||||
private Mock<IIOHelper> _mockIOHelper;
|
||||
private string _testPath = @"c:\test\temp\path";
|
||||
private string _testPath = Path.GetTempPath();
|
||||
|
||||
[Test]
|
||||
public async Task Does_Not_Execute_When_Not_Main_Dom()
|
||||
|
||||
@@ -42,12 +42,12 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Logging
|
||||
|
||||
var loggingConfiguration = TestHelper.GetLoggingConfiguration(hostingEnv);
|
||||
|
||||
var exampleLogfilePath = Path.Combine(testRoot, @"TestHelpers\Assets\", _logfileName);
|
||||
var exampleLogfilePath = Path.Combine(testRoot, "TestHelpers","Assets", _logfileName);
|
||||
_newLogfileDirPath = loggingConfiguration.LogDirectory;
|
||||
_newLogfilePath = Path.Combine(_newLogfileDirPath, _logfileName);
|
||||
|
||||
var exampleSearchfilePath = Path.Combine(testRoot, @"TestHelpers\Assets\", _searchfileName);
|
||||
_newSearchfileDirPath = Path.Combine(hostingEnv.ApplicationPhysicalPath, @"Config\");
|
||||
var exampleSearchfilePath = Path.Combine(testRoot, "TestHelpers","Assets", _searchfileName);
|
||||
_newSearchfileDirPath = Path.Combine(hostingEnv.ApplicationPhysicalPath, @"Config");
|
||||
_newSearchfilePath = Path.Combine(_newSearchfileDirPath, _searchfileName);
|
||||
|
||||
//Create/ensure Directory exists
|
||||
|
||||
@@ -18,6 +18,7 @@ using Umbraco.Web.Routing;
|
||||
using Umbraco.Core.Media;
|
||||
using System;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Core.Serialization;
|
||||
|
||||
namespace Umbraco.Tests.PublishedContent
|
||||
@@ -57,7 +58,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
var dataTypeService = new TestObjects.TestDataTypeService(
|
||||
new DataType(new RichTextPropertyEditor(
|
||||
loggerFactory,
|
||||
Mock.Of<IUmbracoContextAccessor>(),
|
||||
Mock.Of<IBackOfficeSecurityAccessor>(),
|
||||
Mock.Of<IDataTypeService>(),
|
||||
Mock.Of<ILocalizationService>(),
|
||||
imageSourceParser,
|
||||
|
||||
@@ -28,6 +28,7 @@ using Umbraco.Web.Templates;
|
||||
using Umbraco.Web.Routing;
|
||||
using Current = Umbraco.Web.Composing.Current;
|
||||
using Umbraco.Core.Media;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Core.Serialization;
|
||||
|
||||
namespace Umbraco.Tests.PublishedContent
|
||||
@@ -54,6 +55,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
var mediaFileService = Mock.Of<IMediaFileSystem>();
|
||||
var contentTypeBaseServiceProvider = Mock.Of<IContentTypeBaseServiceProvider>();
|
||||
var umbracoContextAccessor = Mock.Of<IUmbracoContextAccessor>();
|
||||
var backOfficeSecurityAccessor = Mock.Of<IBackOfficeSecurityAccessor>();
|
||||
var publishedUrlProvider = Mock.Of<IPublishedUrlProvider>();
|
||||
var imageSourceParser = new HtmlImageSourceParser(publishedUrlProvider);
|
||||
var serializer = new ConfigurationEditorJsonSerializer();
|
||||
@@ -64,7 +66,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
var dataTypeService = new TestObjects.TestDataTypeService(
|
||||
new DataType(new VoidEditor(loggerFactory, Mock.Of<IDataTypeService>(), localizationService, LocalizedTextService, ShortStringHelper), serializer) { Id = 1 },
|
||||
new DataType(new TrueFalsePropertyEditor(loggerFactory, Mock.Of<IDataTypeService>(), localizationService, IOHelper, ShortStringHelper, LocalizedTextService), serializer) { Id = 1001 },
|
||||
new DataType(new RichTextPropertyEditor(loggerFactory,umbracoContextAccessor, Mock.Of<IDataTypeService>(), localizationService, imageSourceParser, linkParser, pastedImages, ShortStringHelper, IOHelper, LocalizedTextService, Mock.Of<IImageUrlGenerator>()), serializer) { Id = 1002 },
|
||||
new DataType(new RichTextPropertyEditor(loggerFactory,backOfficeSecurityAccessor, Mock.Of<IDataTypeService>(), localizationService, imageSourceParser, linkParser, pastedImages, ShortStringHelper, IOHelper, LocalizedTextService, Mock.Of<IImageUrlGenerator>()), serializer) { Id = 1002 },
|
||||
new DataType(new IntegerPropertyEditor(loggerFactory, Mock.Of<IDataTypeService>(), localizationService, ShortStringHelper, LocalizedTextService), serializer) { Id = 1003 },
|
||||
new DataType(new TextboxPropertyEditor(loggerFactory, Mock.Of<IDataTypeService>(), localizationService, IOHelper, ShortStringHelper, LocalizedTextService), serializer) { Id = 1004 },
|
||||
new DataType(new MediaPickerPropertyEditor(loggerFactory, Mock.Of<IDataTypeService>(), localizationService, IOHelper, ShortStringHelper, LocalizedTextService), serializer) { Id = 1005 });
|
||||
|
||||
@@ -19,6 +19,7 @@ using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Core.Templates;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Tests.Common;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
@@ -113,7 +114,7 @@ namespace Umbraco.Tests.Testing.TestingTests
|
||||
var membershipHelper = new MembershipHelper(Mock.Of<IHttpContextAccessor>(), Mock.Of<IPublishedMemberCache>(), membershipProvider, Mock.Of<RoleProvider>(), memberService, memberTypeService, Mock.Of<IPublicAccessService>(), AppCaches.Disabled, NullLoggerFactory.Instance, ShortStringHelper, Mock.Of<IEntityService>());
|
||||
var umbracoMapper = new UmbracoMapper(new MapDefinitionCollection(new[] { Mock.Of<IMapDefinition>() }));
|
||||
|
||||
var umbracoApiController = new FakeUmbracoApiController(new GlobalSettings(), Mock.Of<IUmbracoContextAccessor>(), Mock.Of<ISqlContext>(), ServiceContext.CreatePartial(), AppCaches.NoCache, profilingLogger , Mock.Of<IRuntimeState>(), umbracoMapper, Mock.Of<IPublishedUrlProvider>());
|
||||
var umbracoApiController = new FakeUmbracoApiController(new GlobalSettings(), Mock.Of<IUmbracoContextAccessor>(), Mock.Of<IBackOfficeSecurityAccessor>(), Mock.Of<ISqlContext>(), ServiceContext.CreatePartial(), AppCaches.NoCache, profilingLogger , Mock.Of<IRuntimeState>(), umbracoMapper, Mock.Of<IPublishedUrlProvider>());
|
||||
|
||||
Assert.Pass();
|
||||
}
|
||||
@@ -121,7 +122,7 @@ namespace Umbraco.Tests.Testing.TestingTests
|
||||
|
||||
internal class FakeUmbracoApiController : UmbracoApiController
|
||||
{
|
||||
public FakeUmbracoApiController(GlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoMapper umbracoMapper, IPublishedUrlProvider publishedUrlProvider)
|
||||
: base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoMapper, publishedUrlProvider) { }
|
||||
public FakeUmbracoApiController(GlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoMapper umbracoMapper, IPublishedUrlProvider publishedUrlProvider)
|
||||
: base(globalSettings, umbracoContextAccessor, backOfficeSecurityAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoMapper, publishedUrlProvider) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,6 +313,7 @@ namespace Umbraco.Tests.Testing
|
||||
|
||||
// web
|
||||
Composition.Services.AddUnique(_ => Umbraco.Web.Composing.Current.UmbracoContextAccessor);
|
||||
Composition.Services.AddUnique<IBackOfficeSecurityAccessor>(_ => new HybridBackofficeSecurityAccessor(AppCaches.NoCache.RequestCache));
|
||||
Composition.Services.AddUnique<IPublishedRouter, PublishedRouter>();
|
||||
Composition.WithCollectionBuilder<ContentFinderCollectionBuilder>();
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ using Umbraco.Core.Configuration.Models;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Mapping;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Core.Strings.Css;
|
||||
@@ -34,7 +35,8 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
private readonly IIOHelper _ioHelper;
|
||||
private readonly IFileSystems _fileSystems;
|
||||
private readonly IFileService _fileService;
|
||||
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
|
||||
private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor;
|
||||
|
||||
private readonly ILocalizedTextService _localizedTextService;
|
||||
private readonly UmbracoMapper _umbracoMapper;
|
||||
private readonly IShortStringHelper _shortStringHelper;
|
||||
@@ -44,7 +46,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
IIOHelper ioHelper,
|
||||
IFileSystems fileSystems,
|
||||
IFileService fileService,
|
||||
IUmbracoContextAccessor umbracoContextAccessor,
|
||||
IBackOfficeSecurityAccessor backOfficeSecurityAccessor,
|
||||
ILocalizedTextService localizedTextService,
|
||||
UmbracoMapper umbracoMapper,
|
||||
IShortStringHelper shortStringHelper,
|
||||
@@ -53,7 +55,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
_ioHelper = ioHelper;
|
||||
_fileSystems = fileSystems;
|
||||
_fileService = fileService;
|
||||
_umbracoContextAccessor = umbracoContextAccessor;
|
||||
_backOfficeSecurityAccessor = backOfficeSecurityAccessor;
|
||||
_localizedTextService = localizedTextService;
|
||||
_umbracoMapper = umbracoMapper;
|
||||
_shortStringHelper = shortStringHelper;
|
||||
@@ -72,7 +74,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
if (display == null) throw new ArgumentNullException("display");
|
||||
if (string.IsNullOrWhiteSpace(type)) throw new ArgumentException("Value cannot be null or whitespace.", "type");
|
||||
|
||||
var currentUser = _umbracoContextAccessor.GetRequiredUmbracoContext().Security.CurrentUser;
|
||||
var currentUser = _backOfficeSecurityAccessor.BackOfficeSecurity.CurrentUser;
|
||||
switch (type)
|
||||
{
|
||||
case Core.Constants.Trees.PartialViews:
|
||||
@@ -322,7 +324,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
if (string.IsNullOrWhiteSpace(virtualPath)) throw new ArgumentException("Value cannot be null or whitespace.", "virtualPath");
|
||||
|
||||
virtualPath = System.Web.HttpUtility.UrlDecode(virtualPath);
|
||||
var currentUser = _umbracoContextAccessor.GetRequiredUmbracoContext().Security.CurrentUser;
|
||||
var currentUser = _backOfficeSecurityAccessor.BackOfficeSecurity.CurrentUser;
|
||||
switch (type)
|
||||
{
|
||||
case Constants.Trees.PartialViews:
|
||||
@@ -555,7 +557,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
? relPath + display.Name
|
||||
: relPath.EnsureEndsWith('/') + display.Name;
|
||||
}
|
||||
var currentUser = _umbracoContextAccessor.GetRequiredUmbracoContext().Security.CurrentUser;
|
||||
var currentUser = _backOfficeSecurityAccessor.BackOfficeSecurity.CurrentUser;
|
||||
var file = getFileByName(relPath);
|
||||
if (file != null)
|
||||
{
|
||||
@@ -608,7 +610,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
display.Name = EnsureCorrectFileExtension(display.Name, ".cshtml");
|
||||
|
||||
Attempt<IPartialView> partialViewResult;
|
||||
var currentUser = _umbracoContextAccessor.GetRequiredUmbracoContext().Security.CurrentUser;
|
||||
var currentUser = _backOfficeSecurityAccessor.BackOfficeSecurity.CurrentUser;
|
||||
|
||||
var virtualPath = NormalizeVirtualPath(display.VirtualPath, systemDirectory);
|
||||
var view = getView(virtualPath);
|
||||
|
||||
@@ -15,6 +15,7 @@ using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Core.Dashboards;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Web.Services;
|
||||
using Umbraco.Web.BackOffice.Filters;
|
||||
using Umbraco.Web.Common.Attributes;
|
||||
@@ -32,7 +33,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
[UmbracoBackOfficeAuthorize]
|
||||
public class DashboardController : UmbracoApiController
|
||||
{
|
||||
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
|
||||
private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor;
|
||||
private readonly AppCaches _appCaches;
|
||||
private readonly ILogger<DashboardController> _logger;
|
||||
private readonly IDashboardService _dashboardService;
|
||||
@@ -43,18 +44,15 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
/// Initializes a new instance of the <see cref="DashboardController"/> with all its dependencies.
|
||||
/// </summary>
|
||||
public DashboardController(
|
||||
IUmbracoContextAccessor umbracoContextAccessor,
|
||||
ISqlContext sqlContext,
|
||||
ServiceContext services,
|
||||
IBackOfficeSecurityAccessor backOfficeSecurityAccessor,
|
||||
AppCaches appCaches,
|
||||
ILogger<DashboardController> logger,
|
||||
IRuntimeState runtimeState,
|
||||
IDashboardService dashboardService,
|
||||
IUmbracoVersion umbracoVersion,
|
||||
IShortStringHelper shortStringHelper)
|
||||
|
||||
{
|
||||
_umbracoContextAccessor = umbracoContextAccessor;
|
||||
_backOfficeSecurityAccessor = backOfficeSecurityAccessor;
|
||||
_appCaches = appCaches;
|
||||
_logger = logger;
|
||||
_dashboardService = dashboardService;
|
||||
@@ -69,7 +67,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
[ValidateAngularAntiForgeryToken]
|
||||
public async Task<JObject> GetRemoteDashboardContent(string section, string baseUrl = "https://dashboard.umbraco.org/")
|
||||
{
|
||||
var user = _umbracoContextAccessor.GetRequiredUmbracoContext().Security.CurrentUser;
|
||||
var user = _backOfficeSecurityAccessor.BackOfficeSecurity.CurrentUser;
|
||||
var allowedSections = string.Join(",", user.AllowedSections);
|
||||
var language = user.Language;
|
||||
var version = _umbracoVersion.SemanticVersion.ToSemanticString();
|
||||
@@ -214,7 +212,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
[TypeFilter(typeof(OutgoingEditorModelEventAttribute))]
|
||||
public IEnumerable<Tab<IDashboardSlim>> GetDashboard(string section)
|
||||
{
|
||||
var currentUser = _umbracoContextAccessor.GetRequiredUmbracoContext().Security.CurrentUser;
|
||||
var currentUser = _backOfficeSecurityAccessor.BackOfficeSecurity.CurrentUser;
|
||||
return _dashboardService.GetDashboards(section, currentUser).Select(x => new Tab<IDashboardSlim>
|
||||
{
|
||||
Id = x.Id,
|
||||
|
||||
@@ -12,6 +12,7 @@ using Umbraco.Core.Configuration.Models;
|
||||
using Umbraco.Core.Mapping;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Core.Serialization;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.BackOffice.Filters;
|
||||
@@ -43,7 +44,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
private readonly IMediaTypeService _mediaTypeService;
|
||||
private readonly IMemberTypeService _memberTypeService;
|
||||
private readonly ILocalizedTextService _localizedTextService;
|
||||
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
|
||||
private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor;
|
||||
private readonly IConfigurationEditorJsonSerializer _serializer;
|
||||
|
||||
public DataTypeController(
|
||||
@@ -56,7 +57,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
IMediaTypeService mediaTypeService,
|
||||
IMemberTypeService memberTypeService,
|
||||
ILocalizedTextService localizedTextService,
|
||||
IUmbracoContextAccessor umbracoContextAccessor,
|
||||
IBackOfficeSecurityAccessor backOfficeSecurityAccessor,
|
||||
IConfigurationEditorJsonSerializer serializer)
|
||||
{
|
||||
_propertyEditors = propertyEditors ?? throw new ArgumentNullException(nameof(propertyEditors));
|
||||
@@ -68,7 +69,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
_mediaTypeService = mediaTypeService ?? throw new ArgumentNullException(nameof(mediaTypeService));
|
||||
_memberTypeService = memberTypeService ?? throw new ArgumentNullException(nameof(memberTypeService));
|
||||
_localizedTextService = localizedTextService ?? throw new ArgumentNullException(nameof(localizedTextService));
|
||||
_umbracoContextAccessor = umbracoContextAccessor ?? throw new ArgumentNullException(nameof(umbracoContextAccessor));
|
||||
_backOfficeSecurityAccessor = backOfficeSecurityAccessor ?? throw new ArgumentNullException(nameof(backOfficeSecurityAccessor));
|
||||
_serializer = serializer ?? throw new ArgumentNullException(nameof(serializer));
|
||||
}
|
||||
|
||||
@@ -149,7 +150,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||
}
|
||||
var currentUser = _umbracoContextAccessor.GetRequiredUmbracoContext().Security.CurrentUser;
|
||||
var currentUser = _backOfficeSecurityAccessor.BackOfficeSecurity.CurrentUser;
|
||||
_dataTypeService.Delete(foundType, currentUser.Id);
|
||||
|
||||
return Ok();
|
||||
@@ -249,7 +250,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
public IActionResult DeleteContainer(int id)
|
||||
{
|
||||
|
||||
var currentUser = _umbracoContextAccessor.GetRequiredUmbracoContext().Security.CurrentUser;
|
||||
var currentUser = _backOfficeSecurityAccessor.BackOfficeSecurity.CurrentUser;
|
||||
_dataTypeService.DeleteContainer(id, currentUser.Id);
|
||||
|
||||
return Ok();
|
||||
@@ -257,7 +258,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
|
||||
public IActionResult PostCreateContainer(int parentId, string name)
|
||||
{
|
||||
var currentUser = _umbracoContextAccessor.GetRequiredUmbracoContext().Security.CurrentUser;
|
||||
var currentUser = _backOfficeSecurityAccessor.BackOfficeSecurity.CurrentUser;
|
||||
var result = _dataTypeService.CreateContainer(parentId, name, currentUser.Id);
|
||||
|
||||
return result
|
||||
@@ -287,7 +288,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
|
||||
dataType.PersistedDataType.Configuration = configuration;
|
||||
|
||||
var currentUser = _umbracoContextAccessor.GetRequiredUmbracoContext().Security.CurrentUser;
|
||||
var currentUser = _backOfficeSecurityAccessor.BackOfficeSecurity.CurrentUser;
|
||||
// save the data type
|
||||
try
|
||||
{
|
||||
@@ -344,7 +345,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
|
||||
public IActionResult PostRenameContainer(int id, string name)
|
||||
{
|
||||
var currentUser = _umbracoContextAccessor.GetRequiredUmbracoContext().Security.CurrentUser;
|
||||
var currentUser = _backOfficeSecurityAccessor.BackOfficeSecurity.CurrentUser;
|
||||
var result = _dataTypeService.RenameContainer(id, name, currentUser.Id);
|
||||
|
||||
return result
|
||||
|
||||
@@ -8,6 +8,7 @@ using Umbraco.Core.Mapping;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.Models.Mapping;
|
||||
@@ -34,6 +35,7 @@ namespace Umbraco.Web.BackOffice.Mapping
|
||||
private readonly ILoggerFactory _loggerFactory;
|
||||
private readonly IUserService _userService;
|
||||
private readonly IEntityService _entityService;
|
||||
private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor;
|
||||
private readonly IVariationContextAccessor _variationContextAccessor;
|
||||
private readonly IPublishedUrlProvider _publishedUrlProvider;
|
||||
private readonly UriUtility _uriUtility;
|
||||
@@ -43,9 +45,25 @@ namespace Umbraco.Web.BackOffice.Mapping
|
||||
private readonly ContentVariantMapper _contentVariantMapper;
|
||||
|
||||
|
||||
public ContentMapDefinition(CommonMapper commonMapper, CommonTreeNodeMapper commonTreeNodeMapper, ICultureDictionary cultureDictionary, ILocalizedTextService localizedTextService, IContentService contentService, IContentTypeService contentTypeService,
|
||||
IFileService fileService, IUmbracoContextAccessor umbracoContextAccessor, IPublishedRouter publishedRouter, ILocalizationService localizationService, ILoggerFactory loggerFactory,
|
||||
IUserService userService, IVariationContextAccessor variationContextAccessor, IContentTypeBaseServiceProvider contentTypeBaseServiceProvider, UriUtility uriUtility, IPublishedUrlProvider publishedUrlProvider, IEntityService entityService)
|
||||
public ContentMapDefinition(
|
||||
CommonMapper commonMapper,
|
||||
CommonTreeNodeMapper commonTreeNodeMapper,
|
||||
ICultureDictionary cultureDictionary,
|
||||
ILocalizedTextService localizedTextService,
|
||||
IContentService contentService,
|
||||
IContentTypeService contentTypeService,
|
||||
IFileService fileService,
|
||||
IUmbracoContextAccessor umbracoContextAccessor,
|
||||
IPublishedRouter publishedRouter,
|
||||
ILocalizationService localizationService,
|
||||
ILoggerFactory loggerFactory,
|
||||
IUserService userService,
|
||||
IVariationContextAccessor variationContextAccessor,
|
||||
IContentTypeBaseServiceProvider contentTypeBaseServiceProvider,
|
||||
UriUtility uriUtility,
|
||||
IPublishedUrlProvider publishedUrlProvider,
|
||||
IEntityService entityService,
|
||||
IBackOfficeSecurityAccessor backOfficeSecurityAccessor)
|
||||
{
|
||||
_commonMapper = commonMapper;
|
||||
_commonTreeNodeMapper = commonTreeNodeMapper;
|
||||
@@ -60,6 +78,7 @@ namespace Umbraco.Web.BackOffice.Mapping
|
||||
_loggerFactory = loggerFactory;
|
||||
_userService = userService;
|
||||
_entityService = entityService;
|
||||
_backOfficeSecurityAccessor = backOfficeSecurityAccessor;
|
||||
_variationContextAccessor = variationContextAccessor;
|
||||
_uriUtility = uriUtility;
|
||||
_publishedUrlProvider = publishedUrlProvider;
|
||||
@@ -159,10 +178,10 @@ namespace Umbraco.Web.BackOffice.Mapping
|
||||
|
||||
private IEnumerable<string> GetActions(IContent source)
|
||||
{
|
||||
var umbracoContext = _umbracoContextAccessor.UmbracoContext;
|
||||
var backOfficeSecurity = _backOfficeSecurityAccessor.BackOfficeSecurity;
|
||||
|
||||
//cannot check permissions without a context
|
||||
if (umbracoContext == null)
|
||||
if (backOfficeSecurity is null)
|
||||
return Enumerable.Empty<string>();
|
||||
|
||||
string path;
|
||||
@@ -174,10 +193,7 @@ namespace Umbraco.Web.BackOffice.Mapping
|
||||
path = parent == null ? "-1" : parent.Path;
|
||||
}
|
||||
|
||||
// TODO: This is certainly not ideal usage here - perhaps the best way to deal with this in the future is
|
||||
// with the IUmbracoContextAccessor. In the meantime, if used outside of a web app this will throw a null
|
||||
// reference exception :(
|
||||
return _userService.GetPermissionsForPath(umbracoContext.Security.CurrentUser, path).GetAllPermissions();
|
||||
return _userService.GetPermissionsForPath(backOfficeSecurity.CurrentUser, path).GetAllPermissions();
|
||||
}
|
||||
|
||||
private UrlInfo[] GetUrls(IContent source)
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
/// <summary>
|
||||
/// A marker interface to designate that a controller will be used for Umbraco front-end requests and/or route hijacking
|
||||
/// </summary>
|
||||
/// Migrated already to .Net Core
|
||||
public interface IRenderController
|
||||
{
|
||||
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
using System;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Mvc.Html;
|
||||
using Microsoft.AspNetCore.Html;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
|
||||
namespace Umbraco.Web
|
||||
namespace Umbraco.Extensions
|
||||
{
|
||||
public static class GridTemplateExtensions
|
||||
{
|
||||
public static MvcHtmlString GetGridHtml(this HtmlHelper html, IPublishedProperty property, string framework = "bootstrap3")
|
||||
public static IHtmlContent GetGridHtml(this IHtmlHelper html, IPublishedProperty property, string framework = "bootstrap3")
|
||||
{
|
||||
var asString = property.GetValue() as string;
|
||||
if (asString != null && string.IsNullOrEmpty(asString)) return new MvcHtmlString(string.Empty);
|
||||
if (asString != null && string.IsNullOrEmpty(asString)) return new HtmlString(string.Empty);
|
||||
|
||||
var view = "Grid/" + framework;
|
||||
return html.Partial(view, property.GetValue());
|
||||
}
|
||||
|
||||
public static MvcHtmlString GetGridHtml(this HtmlHelper html, IPublishedContent contentItem)
|
||||
public static IHtmlContent GetGridHtml(this IHtmlHelper html, IPublishedContent contentItem)
|
||||
{
|
||||
return html.GetGridHtml(contentItem, "bodyText", "bootstrap3");
|
||||
}
|
||||
|
||||
public static MvcHtmlString GetGridHtml(this HtmlHelper html, IPublishedContent contentItem, string propertyAlias)
|
||||
public static IHtmlContent GetGridHtml(this IHtmlHelper html, IPublishedContent contentItem, string propertyAlias)
|
||||
{
|
||||
if (propertyAlias == null) throw new ArgumentNullException(nameof(propertyAlias));
|
||||
if (string.IsNullOrWhiteSpace(propertyAlias)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(propertyAlias));
|
||||
@@ -29,7 +29,7 @@ namespace Umbraco.Web
|
||||
return html.GetGridHtml(contentItem, propertyAlias, "bootstrap3");
|
||||
}
|
||||
|
||||
public static MvcHtmlString GetGridHtml(this HtmlHelper html, IPublishedContent contentItem, string propertyAlias, string framework)
|
||||
public static IHtmlContent GetGridHtml(this IHtmlHelper html, IPublishedContent contentItem, string propertyAlias, string framework)
|
||||
{
|
||||
if (propertyAlias == null) throw new ArgumentNullException(nameof(propertyAlias));
|
||||
if (string.IsNullOrWhiteSpace(propertyAlias)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(propertyAlias));
|
||||
@@ -40,17 +40,17 @@ namespace Umbraco.Web
|
||||
var model = prop.GetValue();
|
||||
|
||||
var asString = model as string;
|
||||
if (asString != null && string.IsNullOrEmpty(asString)) return new MvcHtmlString(string.Empty);
|
||||
if (asString != null && string.IsNullOrEmpty(asString)) return new HtmlString(string.Empty);
|
||||
|
||||
return html.Partial(view, model);
|
||||
}
|
||||
|
||||
public static MvcHtmlString GetGridHtml(this HtmlHelper html, IPublishedElement contentItem)
|
||||
public static IHtmlContent GetGridHtml(this IHtmlHelper html, IPublishedElement contentItem)
|
||||
{
|
||||
return html.GetGridHtml(contentItem, "bodyText", "bootstrap3");
|
||||
}
|
||||
|
||||
public static MvcHtmlString GetGridHtml(this HtmlHelper html, IPublishedElement contentItem, string propertyAlias)
|
||||
public static IHtmlContent GetGridHtml(this IHtmlHelper html, IPublishedElement contentItem, string propertyAlias)
|
||||
{
|
||||
if (propertyAlias == null) throw new ArgumentNullException(nameof(propertyAlias));
|
||||
if (string.IsNullOrWhiteSpace(propertyAlias)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(propertyAlias));
|
||||
@@ -58,7 +58,7 @@ namespace Umbraco.Web
|
||||
return html.GetGridHtml(contentItem, propertyAlias, "bootstrap3");
|
||||
}
|
||||
|
||||
public static MvcHtmlString GetGridHtml(this HtmlHelper html, IPublishedElement contentItem, string propertyAlias, string framework)
|
||||
public static IHtmlContent GetGridHtml(this IHtmlHelper html, IPublishedElement contentItem, string propertyAlias, string framework)
|
||||
{
|
||||
if (propertyAlias == null) throw new ArgumentNullException(nameof(propertyAlias));
|
||||
if (string.IsNullOrWhiteSpace(propertyAlias)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(propertyAlias));
|
||||
@@ -69,25 +69,25 @@ namespace Umbraco.Web
|
||||
var model = prop.GetValue();
|
||||
|
||||
var asString = model as string;
|
||||
if (asString != null && string.IsNullOrEmpty(asString)) return new MvcHtmlString(string.Empty);
|
||||
if (asString != null && string.IsNullOrEmpty(asString)) return new HtmlString(string.Empty);
|
||||
|
||||
return html.Partial(view, model);
|
||||
}
|
||||
public static MvcHtmlString GetGridHtml(this IPublishedProperty property, HtmlHelper html, string framework = "bootstrap3")
|
||||
public static IHtmlContent GetGridHtml(this IPublishedProperty property, IHtmlHelper html, string framework = "bootstrap3")
|
||||
{
|
||||
var asString = property.GetValue() as string;
|
||||
if (asString != null && string.IsNullOrEmpty(asString)) return new MvcHtmlString(string.Empty);
|
||||
if (asString != null && string.IsNullOrEmpty(asString)) return new HtmlString(string.Empty);
|
||||
|
||||
var view = "Grid/" + framework;
|
||||
return html.Partial(view, property.GetValue());
|
||||
}
|
||||
|
||||
public static MvcHtmlString GetGridHtml(this IPublishedContent contentItem, HtmlHelper html)
|
||||
public static IHtmlContent GetGridHtml(this IPublishedContent contentItem, IHtmlHelper html)
|
||||
{
|
||||
return GetGridHtml(contentItem, html, "bodyText", "bootstrap3");
|
||||
}
|
||||
|
||||
public static MvcHtmlString GetGridHtml(this IPublishedContent contentItem, HtmlHelper html, string propertyAlias)
|
||||
public static IHtmlContent GetGridHtml(this IPublishedContent contentItem, IHtmlHelper html, string propertyAlias)
|
||||
{
|
||||
if (propertyAlias == null) throw new ArgumentNullException(nameof(propertyAlias));
|
||||
if (string.IsNullOrWhiteSpace(propertyAlias)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(propertyAlias));
|
||||
@@ -95,7 +95,7 @@ namespace Umbraco.Web
|
||||
return GetGridHtml(contentItem, html, propertyAlias, "bootstrap3");
|
||||
}
|
||||
|
||||
public static MvcHtmlString GetGridHtml(this IPublishedContent contentItem, HtmlHelper html, string propertyAlias, string framework)
|
||||
public static IHtmlContent GetGridHtml(this IPublishedContent contentItem, IHtmlHelper html, string propertyAlias, string framework)
|
||||
{
|
||||
if (propertyAlias == null) throw new ArgumentNullException(nameof(propertyAlias));
|
||||
if (string.IsNullOrWhiteSpace(propertyAlias)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(propertyAlias));
|
||||
@@ -106,7 +106,7 @@ namespace Umbraco.Web
|
||||
var model = prop.GetValue();
|
||||
|
||||
var asString = model as string;
|
||||
if (asString != null && string.IsNullOrEmpty(asString)) return new MvcHtmlString(string.Empty);
|
||||
if (asString != null && string.IsNullOrEmpty(asString)) return new HtmlString(string.Empty);
|
||||
|
||||
return html.Partial(view, model);
|
||||
}
|
||||
@@ -23,7 +23,7 @@ namespace Umbraco.Web.Common.Filters
|
||||
/// </summary>
|
||||
internal static bool Enable = true;
|
||||
private readonly IHostingEnvironment _hostingEnvironment;
|
||||
private readonly IUmbracoContextAccessor _umbracoContext;
|
||||
private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor;
|
||||
private readonly IRuntimeState _runtimeState;
|
||||
private readonly LinkGenerator _linkGenerator;
|
||||
private readonly bool _redirectToUmbracoLogin;
|
||||
@@ -31,12 +31,13 @@ namespace Umbraco.Web.Common.Filters
|
||||
|
||||
private UmbracoBackOfficeAuthorizeFilter(
|
||||
IHostingEnvironment hostingEnvironment,
|
||||
IUmbracoContextAccessor umbracoContext,
|
||||
IRuntimeState runtimeState, LinkGenerator linkGenerator,
|
||||
IBackOfficeSecurityAccessor backOfficeSecurityAccessor,
|
||||
IRuntimeState runtimeState,
|
||||
LinkGenerator linkGenerator,
|
||||
bool redirectToUmbracoLogin, bool requireApproval, string redirectUrl)
|
||||
{
|
||||
_hostingEnvironment = hostingEnvironment ?? throw new ArgumentNullException(nameof(hostingEnvironment));
|
||||
_umbracoContext = umbracoContext ?? throw new ArgumentNullException(nameof(umbracoContext));
|
||||
_backOfficeSecurityAccessor = backOfficeSecurityAccessor;
|
||||
_runtimeState = runtimeState ?? throw new ArgumentNullException(nameof(runtimeState));
|
||||
_linkGenerator = linkGenerator ?? throw new ArgumentNullException(nameof(linkGenerator));
|
||||
_redirectToUmbracoLogin = redirectToUmbracoLogin;
|
||||
@@ -54,17 +55,17 @@ namespace Umbraco.Web.Common.Filters
|
||||
/// <param name="redirectUrl"></param>
|
||||
public UmbracoBackOfficeAuthorizeFilter(
|
||||
IHostingEnvironment hostingEnvironment,
|
||||
IUmbracoContextAccessor umbracoContext,
|
||||
IBackOfficeSecurityAccessor backOfficeSecurityAccessor,
|
||||
IRuntimeState runtimeState, LinkGenerator linkGenerator,
|
||||
string redirectUrl) : this(hostingEnvironment, umbracoContext, runtimeState, linkGenerator, false, false, redirectUrl)
|
||||
string redirectUrl) : this(hostingEnvironment, backOfficeSecurityAccessor, runtimeState, linkGenerator, false, false, redirectUrl)
|
||||
{
|
||||
}
|
||||
|
||||
public UmbracoBackOfficeAuthorizeFilter(
|
||||
IHostingEnvironment hostingEnvironment,
|
||||
IUmbracoContextAccessor umbracoContext,
|
||||
IBackOfficeSecurityAccessor backOfficeSecurityAccessor,
|
||||
IRuntimeState runtimeState, LinkGenerator linkGenerator,
|
||||
bool redirectToUmbracoLogin, bool requireApproval) : this(hostingEnvironment, umbracoContext, runtimeState, linkGenerator, redirectToUmbracoLogin, requireApproval, null)
|
||||
bool redirectToUmbracoLogin, bool requireApproval) : this(hostingEnvironment, backOfficeSecurityAccessor, runtimeState, linkGenerator, redirectToUmbracoLogin, requireApproval, null)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -99,7 +100,7 @@ namespace Umbraco.Web.Common.Filters
|
||||
// otherwise we need to ensure that a user is logged in
|
||||
return _runtimeState.Level == RuntimeLevel.Install
|
||||
|| _runtimeState.Level == RuntimeLevel.Upgrade
|
||||
|| _umbracoContext.UmbracoContext?.Security.ValidateCurrentUser(false, _requireApproval) == ValidateRequestAttempt.Success;
|
||||
|| _backOfficeSecurityAccessor?.BackOfficeSecurity.ValidateCurrentUser(false, _requireApproval) == ValidateRequestAttempt.Success;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Security;
|
||||
|
||||
namespace Umbraco.Web.Common.Install
|
||||
{
|
||||
@@ -19,33 +19,42 @@ namespace Umbraco.Web.Common.Install
|
||||
|
||||
private class InstallAuthorizeFilter : IAuthorizationFilter
|
||||
{
|
||||
private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor;
|
||||
private readonly IRuntimeState _runtimeState;
|
||||
private readonly ILogger<InstallAuthorizeFilter> _logger;
|
||||
|
||||
public InstallAuthorizeFilter(
|
||||
IBackOfficeSecurityAccessor backOfficeSecurityAccessor,
|
||||
IRuntimeState runtimeState,
|
||||
ILogger<InstallAuthorizeFilter> logger)
|
||||
{
|
||||
_backOfficeSecurityAccessor = backOfficeSecurityAccessor;
|
||||
_runtimeState = runtimeState;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void OnAuthorization(AuthorizationFilterContext authorizationFilterContext)
|
||||
{
|
||||
var serviceProvider = authorizationFilterContext.HttpContext.RequestServices;
|
||||
var runtimeState = serviceProvider.GetService<IRuntimeState>();
|
||||
var umbracoContext = serviceProvider.GetService<IUmbracoContext>();
|
||||
var logger = serviceProvider.GetService<ILogger<InstallAuthorizeFilter>>();
|
||||
|
||||
if (!IsAllowed(runtimeState, umbracoContext, logger))
|
||||
if (!IsAllowed())
|
||||
{
|
||||
authorizationFilterContext.Result = new ForbidResult();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static bool IsAllowed(IRuntimeState runtimeState, IUmbracoContext umbracoContext, ILogger<InstallAuthorizeFilter> logger)
|
||||
private bool IsAllowed()
|
||||
{
|
||||
try
|
||||
{
|
||||
// if not configured (install or upgrade) then we can continue
|
||||
// otherwise we need to ensure that a user is logged in
|
||||
return runtimeState.Level == RuntimeLevel.Install
|
||||
|| runtimeState.Level == RuntimeLevel.Upgrade
|
||||
|| (umbracoContext?.Security?.ValidateCurrentUser() ?? false);
|
||||
return _runtimeState.Level == RuntimeLevel.Install
|
||||
|| _runtimeState.Level == RuntimeLevel.Upgrade
|
||||
|| (_backOfficeSecurityAccessor?.BackOfficeSecurity?.ValidateCurrentUser() ?? false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "An error occurred determining authorization");
|
||||
_logger.LogError(ex, "An error occurred determining authorization");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace Umbraco.Web.Macros
|
||||
private readonly IProfilingLogger _profilingLogger;
|
||||
private readonly ILogger<MacroRenderer> _logger;
|
||||
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
|
||||
private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor;
|
||||
private readonly ContentSettings _contentSettings;
|
||||
private readonly ILocalizedTextService _textService;
|
||||
private readonly AppCaches _appCaches;
|
||||
@@ -40,6 +41,7 @@ namespace Umbraco.Web.Macros
|
||||
IProfilingLogger profilingLogger ,
|
||||
ILogger<MacroRenderer> logger,
|
||||
IUmbracoContextAccessor umbracoContextAccessor,
|
||||
IBackOfficeSecurityAccessor backOfficeSecurityAccessor,
|
||||
IOptions<ContentSettings> contentSettings,
|
||||
ILocalizedTextService textService,
|
||||
AppCaches appCaches,
|
||||
@@ -54,6 +56,7 @@ namespace Umbraco.Web.Macros
|
||||
_profilingLogger = profilingLogger ?? throw new ArgumentNullException(nameof(profilingLogger ));
|
||||
_logger = logger;
|
||||
_umbracoContextAccessor = umbracoContextAccessor ?? throw new ArgumentNullException(nameof(umbracoContextAccessor));
|
||||
_backOfficeSecurityAccessor = backOfficeSecurityAccessor;
|
||||
_contentSettings = contentSettings.Value ?? throw new ArgumentNullException(nameof(contentSettings));
|
||||
_textService = textService;
|
||||
_appCaches = appCaches ?? throw new ArgumentNullException(nameof(appCaches));
|
||||
@@ -89,7 +92,7 @@ namespace Umbraco.Web.Macros
|
||||
{
|
||||
object key = 0;
|
||||
|
||||
if (_umbracoContextAccessor.GetRequiredUmbracoContext().Security.IsAuthenticated())
|
||||
if (_backOfficeSecurityAccessor.BackOfficeSecurity.IsAuthenticated())
|
||||
{
|
||||
key = _memberUserKeyProvider.GetMemberProviderUserKey() ?? 0;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace Umbraco.Web
|
||||
private readonly Lazy<IPublishedSnapshot> _publishedSnapshot;
|
||||
private string _previewToken;
|
||||
private bool? _previewing;
|
||||
private IBackOfficeSecurity _backofficeSecurity;
|
||||
|
||||
// initializes a new instance of the UmbracoContext class
|
||||
// internal for unit tests
|
||||
@@ -46,7 +47,7 @@ namespace Umbraco.Web
|
||||
|
||||
ObjectCreated = DateTime.Now;
|
||||
UmbracoRequestId = Guid.NewGuid();
|
||||
Security = backofficeSecurity ?? throw new ArgumentNullException(nameof(backofficeSecurity));
|
||||
_backofficeSecurity = backofficeSecurity ?? throw new ArgumentNullException(nameof(backofficeSecurity));
|
||||
|
||||
// beware - we cannot expect a current user here, so detecting preview mode must be a lazy thing
|
||||
_publishedSnapshot = new Lazy<IPublishedSnapshot>(() => publishedSnapshotService.CreatePublishedSnapshot(PreviewToken));
|
||||
@@ -74,11 +75,6 @@ namespace Umbraco.Web
|
||||
/// </summary>
|
||||
public Guid UmbracoRequestId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the BackofficeSecurity class
|
||||
/// </summary>
|
||||
public IBackOfficeSecurity Security { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the uri that is handled by ASP.NET after server-side rewriting took place.
|
||||
/// </summary>
|
||||
@@ -168,7 +164,7 @@ namespace Umbraco.Web
|
||||
var requestUrl = _requestAccessor.GetRequestUrl();
|
||||
if (requestUrl != null
|
||||
&& requestUrl.IsBackOfficeRequest(_globalSettings, _hostingEnvironment) == false
|
||||
&& Security.CurrentUser != null)
|
||||
&& _backofficeSecurity.CurrentUser != null)
|
||||
{
|
||||
var previewToken = _cookieManager.GetCookieValue(Constants.Web.PreviewCookieName); // may be null or empty
|
||||
_previewToken = previewToken.IsNullOrWhiteSpace() ? null : previewToken;
|
||||
@@ -190,8 +186,6 @@ namespace Umbraco.Web
|
||||
{
|
||||
// DisposableObject ensures that this runs only once
|
||||
|
||||
Security.DisposeIfDisposable();
|
||||
|
||||
// help caches release resources
|
||||
// (but don't create caches just to dispose them)
|
||||
// context is not multi-threaded
|
||||
|
||||
@@ -21,6 +21,7 @@ using Umbraco.Core.Packaging;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.Runtime;
|
||||
using Umbraco.Core.Scoping;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Core.Sync;
|
||||
@@ -87,6 +88,9 @@ namespace Umbraco.Web.Composing
|
||||
public static IUmbracoContext UmbracoContext
|
||||
=> UmbracoContextAccessor.UmbracoContext;
|
||||
|
||||
public static IBackOfficeSecurityAccessor BackOfficeSecurityAccessor
|
||||
=> Factory.GetRequiredService<IBackOfficeSecurityAccessor>();
|
||||
|
||||
public static UmbracoHelper UmbracoHelper
|
||||
=> Factory.GetRequiredService<UmbracoHelper>();
|
||||
public static IUmbracoComponentRenderer UmbracoComponentRenderer
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Umbraco.Web.Mvc
|
||||
|
||||
private IRuntimeState RuntimeState => _runtimeState ?? Current.RuntimeState;
|
||||
|
||||
private IBackOfficeSecurity BackOfficeSecurity => _backOfficeSecurityAccessor.BackOfficeSecurity ?? Current.UmbracoContext.Security;
|
||||
private IBackOfficeSecurity BackOfficeSecurity => _backOfficeSecurityAccessor.BackOfficeSecurity ?? Current.BackOfficeSecurityAccessor.BackOfficeSecurity;
|
||||
|
||||
/// <summary>
|
||||
/// THIS SHOULD BE ONLY USED FOR UNIT TESTS
|
||||
|
||||
@@ -221,7 +221,6 @@
|
||||
<Compile Include="WebAssets\CDF\UmbracoClientDependencyLoader.cs" />
|
||||
<Compile Include="UmbracoDefaultOwinStartup.cs" />
|
||||
<Compile Include="Mvc\ProfilingView.cs" />
|
||||
<Compile Include="GridTemplateExtensions.cs" />
|
||||
<Compile Include="Mvc\NotFoundHandler.cs" />
|
||||
<Compile Include="Mvc\RedirectToUmbracoUrlResult.cs" />
|
||||
<Compile Include="Mvc\UmbracoVirtualNodeByIdRouteHandler.cs" />
|
||||
|
||||
@@ -13,12 +13,13 @@ namespace Umbraco.Web
|
||||
private UrlHelper _url;
|
||||
|
||||
protected UmbracoHttpHandler()
|
||||
: this(Current.UmbracoContextAccessor, Current.Services, Current.Logger, Current.ProfilingLogger)
|
||||
: this(Current.UmbracoContextAccessor, Current.BackOfficeSecurityAccessor, Current.Services, Current.Logger, Current.ProfilingLogger)
|
||||
{ }
|
||||
|
||||
protected UmbracoHttpHandler(IUmbracoContextAccessor umbracoContextAccessor,ServiceContext service, ILogger logger, IProfilingLogger profilingLogger )
|
||||
protected UmbracoHttpHandler(IUmbracoContextAccessor umbracoContextAccessor, IBackOfficeSecurityAccessor backOfficeSecurityAccessor,ServiceContext service, ILogger logger, IProfilingLogger profilingLogger )
|
||||
{
|
||||
UmbracoContextAccessor = umbracoContextAccessor;
|
||||
BackOfficeSecurityAccessor = backOfficeSecurityAccessor;
|
||||
Logger = logger;
|
||||
ProfilingLogger = profilingLogger ;
|
||||
Services = service;
|
||||
@@ -43,6 +44,8 @@ namespace Umbraco.Web
|
||||
/// </summary>
|
||||
public IUmbracoContextAccessor UmbracoContextAccessor { get; }
|
||||
|
||||
public IBackOfficeSecurityAccessor BackOfficeSecurityAccessor { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the services context.
|
||||
/// </summary>
|
||||
@@ -51,7 +54,7 @@ namespace Umbraco.Web
|
||||
/// <summary>
|
||||
/// Gets the web security helper.
|
||||
/// </summary>
|
||||
public IBackOfficeSecurity Security => UmbracoContextAccessor.UmbracoContext.Security;
|
||||
public IBackOfficeSecurity Security => BackOfficeSecurityAccessor.BackOfficeSecurity;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Url helper.
|
||||
|
||||
@@ -16,17 +16,18 @@ namespace Umbraco.Web
|
||||
{
|
||||
private UrlHelper _url;
|
||||
|
||||
protected UmbracoWebService(ILogger logger, IProfilingLogger profilingLogger, IUmbracoContextAccessor umbracoContextAccessor, ServiceContext services, GlobalSettings globalSettings)
|
||||
protected UmbracoWebService(ILogger logger, IProfilingLogger profilingLogger, IUmbracoContextAccessor umbracoContextAccessor, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, ServiceContext services, GlobalSettings globalSettings)
|
||||
{
|
||||
Logger = logger;
|
||||
ProfilingLogger = profilingLogger;
|
||||
UmbracoContextAccessor = umbracoContextAccessor;
|
||||
BackOfficeSecurityAccessor = backOfficeSecurityAccessor;
|
||||
Services = services;
|
||||
GlobalSettings = globalSettings;
|
||||
}
|
||||
|
||||
protected UmbracoWebService()
|
||||
: this(Current.Logger, Current.ProfilingLogger, Current.UmbracoContextAccessor, Current.Services, new GlobalSettings())
|
||||
: this(Current.Logger, Current.ProfilingLogger, Current.UmbracoContextAccessor, Current.BackOfficeSecurityAccessor, Current.Services,new GlobalSettings())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -50,6 +51,8 @@ namespace Umbraco.Web
|
||||
/// </summary>
|
||||
public IUmbracoContextAccessor UmbracoContextAccessor { get; }
|
||||
|
||||
public IBackOfficeSecurityAccessor BackOfficeSecurityAccessor { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the services context.
|
||||
/// </summary>
|
||||
@@ -63,7 +66,7 @@ namespace Umbraco.Web
|
||||
/// <summary>
|
||||
/// Gets the web security helper.
|
||||
/// </summary>
|
||||
public IBackOfficeSecurity Security => UmbracoContext.Security;
|
||||
public IBackOfficeSecurity Security => BackOfficeSecurityAccessor.BackOfficeSecurity;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Url helper.
|
||||
|
||||
@@ -7,6 +7,7 @@ using Umbraco.Core.Configuration.Models;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Mapping;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Routing;
|
||||
|
||||
@@ -21,8 +22,8 @@ namespace Umbraco.Web.WebApi
|
||||
{
|
||||
}
|
||||
|
||||
protected UmbracoApiController(GlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoMapper umbracoMapper, IPublishedUrlProvider publishedUrlProvider)
|
||||
: base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoMapper, publishedUrlProvider)
|
||||
protected UmbracoApiController(GlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoMapper umbracoMapper, IPublishedUrlProvider publishedUrlProvider)
|
||||
: base(globalSettings, umbracoContextAccessor, backOfficeSecurityAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoMapper, publishedUrlProvider)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ namespace Umbraco.Web.WebApi
|
||||
: this(
|
||||
Current.Factory.GetRequiredService<GlobalSettings>(),
|
||||
Current.Factory.GetRequiredService<IUmbracoContextAccessor>(),
|
||||
Current.Factory.GetRequiredService<IBackOfficeSecurityAccessor>(),
|
||||
Current.Factory.GetRequiredService<ISqlContext>(),
|
||||
Current.Factory.GetRequiredService<ServiceContext>(),
|
||||
Current.Factory.GetRequiredService<AppCaches>(),
|
||||
@@ -54,9 +55,10 @@ namespace Umbraco.Web.WebApi
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UmbracoApiControllerBase"/> class with all its dependencies.
|
||||
/// </summary>
|
||||
protected UmbracoApiControllerBase(GlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoMapper umbracoMapper, IPublishedUrlProvider publishedUrlProvider)
|
||||
protected UmbracoApiControllerBase(GlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoMapper umbracoMapper, IPublishedUrlProvider publishedUrlProvider)
|
||||
{
|
||||
UmbracoContextAccessor = umbracoContextAccessor;
|
||||
BackOfficeSecurityAccessor = backOfficeSecurityAccessor;
|
||||
SqlContext = sqlContext;
|
||||
Services = services;
|
||||
AppCaches = appCaches;
|
||||
@@ -82,6 +84,8 @@ namespace Umbraco.Web.WebApi
|
||||
/// </summary>
|
||||
public virtual IUmbracoContextAccessor UmbracoContextAccessor { get; }
|
||||
|
||||
public IBackOfficeSecurityAccessor BackOfficeSecurityAccessor { get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sql context.
|
||||
@@ -118,7 +122,7 @@ namespace Umbraco.Web.WebApi
|
||||
/// <summary>
|
||||
/// Gets the web security helper.
|
||||
/// </summary>
|
||||
public IBackOfficeSecurity Security => UmbracoContext.Security;
|
||||
public IBackOfficeSecurity Security => BackOfficeSecurityAccessor.BackOfficeSecurity;
|
||||
|
||||
/// <summary>
|
||||
/// Tries to get the current HttpContext.
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Umbraco.Web.WebApi
|
||||
|
||||
private IRuntimeState RuntimeState => _runtimeState ?? Current.RuntimeState;
|
||||
|
||||
private IBackOfficeSecurity BackOfficeSecurity => _backOfficeSecurityAccessor.BackOfficeSecurity ?? Current.UmbracoContext.Security;
|
||||
private IBackOfficeSecurity BackOfficeSecurity => _backOfficeSecurityAccessor.BackOfficeSecurity ?? Current.BackOfficeSecurityAccessor.BackOfficeSecurity;
|
||||
|
||||
/// <summary>
|
||||
/// THIS SHOULD BE ONLY USED FOR UNIT TESTS
|
||||
|
||||
@@ -8,6 +8,7 @@ using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Security;
|
||||
using Umbraco.Core.Mapping;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Web.Routing;
|
||||
|
||||
namespace Umbraco.Web.WebApi
|
||||
@@ -36,8 +37,8 @@ namespace Umbraco.Web.WebApi
|
||||
{
|
||||
}
|
||||
|
||||
protected UmbracoAuthorizedApiController(GlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoMapper umbracoMapper, IPublishedUrlProvider publishedUrlProvider)
|
||||
: base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoMapper, publishedUrlProvider)
|
||||
protected UmbracoAuthorizedApiController(GlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoMapper umbracoMapper, IPublishedUrlProvider publishedUrlProvider)
|
||||
: base(globalSettings, umbracoContextAccessor, backOfficeSecurityAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoMapper, publishedUrlProvider)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user