Merge remote-tracking branch 'origin/netcore/netcore' into netcore/feature/linux-paths
# Conflicts: # src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/HostedServices/TempFileCleanupTests.cs # src/Umbraco.Web.Common/Extensions/UmbracoCoreServiceCollectionExtensions.cs
This commit is contained in:
@@ -3,17 +3,19 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.BackOffice;
|
||||
using Umbraco.Core.Configuration.Models;
|
||||
using Umbraco.Core.Mapping;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Models.Security;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Extensions;
|
||||
@@ -25,12 +27,10 @@ using Umbraco.Web.Common.Controllers;
|
||||
using Umbraco.Web.Common.Exceptions;
|
||||
using Umbraco.Web.Common.Filters;
|
||||
using Umbraco.Web.Common.Security;
|
||||
using Umbraco.Web.Editors.Filters;
|
||||
using Umbraco.Web.Models;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.Security;
|
||||
using Constants = Umbraco.Core.Constants;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Umbraco.Web.Editors.Filters;
|
||||
|
||||
namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
|
||||
@@ -11,6 +11,7 @@ using Umbraco.Core.Hosting;
|
||||
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;
|
||||
@@ -35,7 +36,8 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
private readonly IHostingEnvironment _hostingEnvironment;
|
||||
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;
|
||||
@@ -45,7 +47,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
IHostingEnvironment hostingEnvironment,
|
||||
IFileSystems fileSystems,
|
||||
IFileService fileService,
|
||||
IUmbracoContextAccessor umbracoContextAccessor,
|
||||
IBackOfficeSecurityAccessor backOfficeSecurityAccessor,
|
||||
ILocalizedTextService localizedTextService,
|
||||
UmbracoMapper umbracoMapper,
|
||||
IShortStringHelper shortStringHelper,
|
||||
@@ -54,7 +56,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
_hostingEnvironment = hostingEnvironment;
|
||||
_fileSystems = fileSystems;
|
||||
_fileService = fileService;
|
||||
_umbracoContextAccessor = umbracoContextAccessor;
|
||||
_backOfficeSecurityAccessor = backOfficeSecurityAccessor;
|
||||
_localizedTextService = localizedTextService;
|
||||
_umbracoMapper = umbracoMapper;
|
||||
_shortStringHelper = shortStringHelper;
|
||||
@@ -73,7 +75,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:
|
||||
@@ -323,7 +325,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:
|
||||
@@ -556,7 +558,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)
|
||||
{
|
||||
@@ -609,7 +611,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
|
||||
|
||||
@@ -250,7 +250,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
/// <param name="culture">The culture to fetch the URL for</param>
|
||||
/// <returns>The URL or path to the item</returns>
|
||||
[DetermineAmbiguousActionByPassingParameters]
|
||||
public HttpResponseMessage GetUrl(Udi udi, string culture = "*")
|
||||
public IActionResult GetUrl(Udi udi, string culture = "*")
|
||||
{
|
||||
var intId = _entityService.GetId(udi);
|
||||
if (!intId.Success)
|
||||
@@ -284,7 +284,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
/// We are not restricting this with security because there is no sensitive data
|
||||
/// </remarks>
|
||||
[DetermineAmbiguousActionByPassingParameters]
|
||||
public HttpResponseMessage GetUrl(int id, UmbracoEntityTypes type, string culture = null)
|
||||
public IActionResult GetUrl(int id, UmbracoEntityTypes type, string culture = null)
|
||||
{
|
||||
culture = culture ?? ClientCulture();
|
||||
|
||||
@@ -297,10 +297,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
returnUrl = foundUrl;
|
||||
|
||||
return new HttpResponseMessage(HttpStatusCode.OK)
|
||||
{
|
||||
Content = new StringContent(returnUrl)
|
||||
};
|
||||
return Ok(returnUrl);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,10 +311,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
|
||||
returnUrl = "/" + string.Join("/", ancestors.Select(x => x.Name));
|
||||
|
||||
return new HttpResponseMessage(HttpStatusCode.OK)
|
||||
{
|
||||
Content = new StringContent(returnUrl)
|
||||
};
|
||||
return Ok(returnUrl);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public HttpResponseMessage CreatePartialViewMacroWithFile(CreatePartialViewMacroWithFileModel model)
|
||||
public IActionResult CreatePartialViewMacroWithFile(CreatePartialViewMacroWithFileModel model)
|
||||
{
|
||||
if (model == null) throw new ArgumentNullException("model");
|
||||
if (string.IsNullOrWhiteSpace(model.Filename)) throw new ArgumentException("Filename cannot be null or whitespace", "model.Filename");
|
||||
@@ -173,7 +173,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
};
|
||||
|
||||
_macroService.Save(macro); // may throw
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
public class CreatePartialViewMacroWithFileModel
|
||||
|
||||
Reference in New Issue
Block a user