Merge branch 'v11/dev' into v11/contrib

This commit is contained in:
Sebastiaan Janssen
2022-12-12 13:59:03 +01:00
116 changed files with 1609 additions and 776 deletions

View File

@@ -467,7 +467,7 @@ public class CodeFileController : BackOfficeNotificationsController
{
case Constants.Trees.PartialViews:
if (IsDirectory(
_hostingEnvironment.MapPathContentRoot(Path.Combine(Constants.SystemDirectories.PartialViews, virtualPath))))
_hostingEnvironment.MapPathContentRoot(Path.Combine(Constants.SystemDirectories.PartialViews, virtualPath)), _fileSystems.PartialViewsFileSystem!))
{
_fileService.DeletePartialViewFolder(virtualPath);
return Ok();
@@ -482,7 +482,7 @@ public class CodeFileController : BackOfficeNotificationsController
case Constants.Trees.PartialViewMacros:
if (IsDirectory(
_hostingEnvironment.MapPathContentRoot(Path.Combine(Constants.SystemDirectories.MacroPartials, virtualPath))))
_hostingEnvironment.MapPathContentRoot(Path.Combine(Constants.SystemDirectories.MacroPartials, virtualPath)), _fileSystems.MacroPartialsFileSystem!))
{
_fileService.DeletePartialViewMacroFolder(virtualPath);
return Ok();
@@ -497,7 +497,7 @@ public class CodeFileController : BackOfficeNotificationsController
case Constants.Trees.Scripts:
if (IsDirectory(
_hostingEnvironment.MapPathWebRoot(Path.Combine(_globalSettings.UmbracoScriptsPath, virtualPath))))
_hostingEnvironment.MapPathWebRoot(Path.Combine(_globalSettings.UmbracoScriptsPath, virtualPath)), _fileSystems.ScriptsFileSystem!))
{
_fileService.DeleteScriptFolder(virtualPath);
return Ok();
@@ -512,7 +512,7 @@ public class CodeFileController : BackOfficeNotificationsController
return new UmbracoProblemResult("No Script or folder found with the specified path", HttpStatusCode.NotFound);
case Constants.Trees.Stylesheets:
if (IsDirectory(
_hostingEnvironment.MapPathWebRoot(Path.Combine(_globalSettings.UmbracoCssPath, virtualPath))))
_hostingEnvironment.MapPathWebRoot(Path.Combine(_globalSettings.UmbracoCssPath, virtualPath)), _fileSystems.StylesheetsFileSystem!))
{
_fileService.DeleteStyleSheetFolder(virtualPath);
return Ok();
@@ -827,13 +827,21 @@ public class CodeFileController : BackOfficeNotificationsController
return value;
}
private bool IsDirectory(string path)
private bool IsDirectory(string path, IFileSystem fileSystem)
{
var dirInfo = new DirectoryInfo(path);
// If it's a physical filesystem check with directory info
if (fileSystem.CanAddPhysical)
{
var dirInfo = new DirectoryInfo(path);
// If you turn off indexing in Windows this will have the attribute:
// `FileAttributes.Directory | FileAttributes.NotContentIndexed`
return (dirInfo.Attributes & FileAttributes.Directory) != 0;
// If you turn off indexing in Windows this will have the attribute:
// `FileAttributes.Directory | FileAttributes.NotContentIndexed`
return (dirInfo.Attributes & FileAttributes.Directory) != 0;
}
// Otherwise check the filesystem abstraction to see if the folder exists
// Since this is used for delete, it presumably exists if we're trying to delete it
return fileSystem.DirectoryExists(path);
}
// this is an internal class for passing stylesheet data from the client to the controller while editing

View File

@@ -146,7 +146,9 @@ public abstract class ContentControllerBase : BackOfficeNotificationsController
// set the value - tags are special
TagsPropertyEditorAttribute? tagAttribute = propertyDto.PropertyEditor.GetTagAttribute();
if (tagAttribute != null)
// when TagsPropertyEditorAttribute is removed this whole if can also be removed
// since the call to sovePropertyValue is all that's needed now
if (tagAttribute is not null && valueEditor is not IDataValueTags)
{
TagConfiguration? tagConfiguration =
ConfigurationEditor.ConfigurationAs<TagConfiguration>(propertyDto.DataType?.Configuration);

View File

@@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.ContentApps;
@@ -25,6 +26,7 @@ using Umbraco.Cms.Web.BackOffice.Filters;
using Umbraco.Cms.Web.BackOffice.ModelBinders;
using Umbraco.Cms.Web.Common.Attributes;
using Umbraco.Cms.Web.Common.Authorization;
using Umbraco.Cms.Web.Common.DependencyInjection;
using Umbraco.Cms.Web.Common.Filters;
using Umbraco.Cms.Web.Common.Security;
using Umbraco.Extensions;
@@ -50,6 +52,7 @@ public class MemberController : ContentControllerBase
private readonly IPasswordChanger<MemberIdentityUser> _passwordChanger;
private readonly PropertyEditorCollection _propertyEditors;
private readonly ICoreScopeProvider _scopeProvider;
private readonly ITwoFactorLoginService _twoFactorLoginService;
private readonly IShortStringHelper _shortStringHelper;
private readonly IUmbracoMapper _umbracoMapper;
@@ -71,6 +74,43 @@ public class MemberController : ContentControllerBase
/// <param name="jsonSerializer">The JSON serializer</param>
/// <param name="passwordChanger">The password changer</param>
/// <param name="scopeProvider">The core scope provider</param>
/// <param name="twoFactorLoginService">The two factor login service</param>
[ActivatorUtilitiesConstructor]
public MemberController(
ICultureDictionary cultureDictionary,
ILoggerFactory loggerFactory,
IShortStringHelper shortStringHelper,
IEventMessagesFactory eventMessages,
ILocalizedTextService localizedTextService,
PropertyEditorCollection propertyEditors,
IUmbracoMapper umbracoMapper,
IMemberService memberService,
IMemberTypeService memberTypeService,
IMemberManager memberManager,
IDataTypeService dataTypeService,
IBackOfficeSecurityAccessor backOfficeSecurityAccessor,
IJsonSerializer jsonSerializer,
IPasswordChanger<MemberIdentityUser> passwordChanger,
ICoreScopeProvider scopeProvider,
ITwoFactorLoginService twoFactorLoginService)
: base(cultureDictionary, loggerFactory, shortStringHelper, eventMessages, localizedTextService, jsonSerializer)
{
_propertyEditors = propertyEditors;
_umbracoMapper = umbracoMapper;
_memberService = memberService;
_memberTypeService = memberTypeService;
_memberManager = memberManager;
_dataTypeService = dataTypeService;
_localizedTextService = localizedTextService;
_backOfficeSecurityAccessor = backOfficeSecurityAccessor;
_jsonSerializer = jsonSerializer;
_shortStringHelper = shortStringHelper;
_passwordChanger = passwordChanger;
_scopeProvider = scopeProvider;
_twoFactorLoginService = twoFactorLoginService;
}
[Obsolete("Use constructor that also takes an ITwoFactorLoginService. Scheduled for removal in V13")]
public MemberController(
ICultureDictionary cultureDictionary,
ILoggerFactory loggerFactory,
@@ -87,20 +127,24 @@ public class MemberController : ContentControllerBase
IJsonSerializer jsonSerializer,
IPasswordChanger<MemberIdentityUser> passwordChanger,
ICoreScopeProvider scopeProvider)
: base(cultureDictionary, loggerFactory, shortStringHelper, eventMessages, localizedTextService, jsonSerializer)
: this(
cultureDictionary,
loggerFactory,
shortStringHelper,
eventMessages,
localizedTextService,
propertyEditors,
umbracoMapper,
memberService,
memberTypeService,
memberManager,
dataTypeService,
backOfficeSecurityAccessor,
jsonSerializer,
passwordChanger,
scopeProvider,
StaticServiceProvider.Instance.GetRequiredService<ITwoFactorLoginService>())
{
_propertyEditors = propertyEditors;
_umbracoMapper = umbracoMapper;
_memberService = memberService;
_memberTypeService = memberTypeService;
_memberManager = memberManager;
_dataTypeService = dataTypeService;
_localizedTextService = localizedTextService;
_backOfficeSecurityAccessor = backOfficeSecurityAccessor;
_jsonSerializer = jsonSerializer;
_shortStringHelper = shortStringHelper;
_passwordChanger = passwordChanger;
_scopeProvider = scopeProvider;
}
/// <summary>
@@ -544,6 +588,16 @@ public class MemberController : ContentControllerBase
return ValidationProblem("An admin cannot lock a member");
}
// Handle disabling of 2FA
if (!contentItem.IsTwoFactorEnabled)
{
IEnumerable<string> providers = await _twoFactorLoginService.GetEnabledTwoFactorProviderNamesAsync(contentItem.Key);
foreach (var provider in providers)
{
await _twoFactorLoginService.DisableAsync(contentItem.Key, provider);
}
}
// If we're changing the password...
// Handle changing with the member manager & password changer (takes care of other nuances)
if (contentItem.Password != null)