V10: Fix build warnings in core (#12438)
* Run code cleanup * Start manual cleanup after dotnet format * Finish up manual pass * Fix up missed warnings * Fix after merge * Update src/Umbraco.Core/Cache/ContentTypeCacheRefresher.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Cache/DataTypeCacheRefresher.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Cache/DeepCloneAppCache.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Cache/DomainCacheRefresher.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Cache/FastDictionaryAppCacheBase.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Cache/FastDictionaryAppCacheBase.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Cache/FastDictionaryAppCacheBase.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Cache/FastDictionaryAppCacheBase.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Cache/FastDictionaryAppCacheBase.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Cache/MacroCacheRefresher.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Cache/MediaCacheRefresher.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Cache/MemberCacheRefresher.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Cache/MemberGroupCacheRefresher.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Composing/OrderedCollectionBuilderBase.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Configuration/Models/RequestHandlerSettings.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Composing/SetCollectionBuilderBase.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Composing/WeightedCollectionBuilderBase.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/ContentApps/ContentAppFactoryCollectionBuilder.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Dashboards/DashboardCollectionBuilder.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Extensions/StringExtensions.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Extensions/StringExtensions.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Extensions/StringExtensions.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Extensions/StringExtensions.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Extensions/StringExtensions.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Extensions/StringExtensions.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Extensions/StringExtensions.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/ContentTypeRefreshedNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/ContentTypeSavedNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/ContentTypeSavingNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/DictionaryCacheRefresherNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/DataTypeCacheRefresherNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/ContentUnpublishingNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/DictionaryItemDeletingNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/DictionaryItemSavedNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/DictionaryItemSavingNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/DomainCacheRefresherNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/LanguageCacheRefresherNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MacroCacheRefresherNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MediaCacheRefresherNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MediaEmptiedRecycleBinNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MediaEmptyingRecycleBinNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MediaMovedNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MediaMovedToRecycleBinNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Extensions/StringExtensions.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Extensions/StringExtensions.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Extensions/StringExtensions.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Extensions/StringExtensions.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Extensions/StringExtensions.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Extensions/StringExtensions.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MediaMovedToRecycleBinNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MediaMovingNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MediaMovingToRecycleBinNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MediaTreeChangeNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MediaTreeChangeNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MediaTypeChangedNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MediaTypeDeletingNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MediaTypeMovedNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MediaTypeMovingNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MediaTypeMovingNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MediaTypeRefreshedNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MemberCacheRefresherNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MemberGroupCacheRefresherNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MemberGroupDeletingNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MemberGroupSavedNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MemberGroupSavingNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MemberTypeChangedNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MemberTypeDeletedNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MemberTypeDeletingNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MemberTypeMovedNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MemberTypeMovedNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MemberTypeMovingNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MemberTypeMovingNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MemberTypeRefreshedNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MemberTypeSavingNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Extensions/StringExtensions.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Extensions/UriExtensions.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MovedToRecycleBinNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MovedToRecycleBinNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MovingToRecycleBinNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/MovingToRecycleBinNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/PartialViewDeletingNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Extensions/UriExtensions.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/IO/PhysicalFileSystem.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/IO/PhysicalFileSystem.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/IO/ShadowWrapper.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Logging/DisposableTimer.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Install/InstallSteps/UpgradeStep.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Mapping/MapDefinitionCollectionBuilder.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Media/EmbedProviders/EmbedProvidersCollectionBuilder.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/PartialViewSavedNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Models/ContentEditing/ContentVariationDisplay.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/PartialViewSavingNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/PublicAccessCacheRefresherNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/PublicAccessEntryDeletedNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/PublicAccessEntryDeletingNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/PublicAccessEntryDeletingNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/PublicAccessEntrySavedNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/PublicAccessEntrySavingNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/PublicAccessEntrySavingNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/RelationTypeCacheRefresherNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/RelationTypeDeletingNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/RelationTypeSavedNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/RelationTypeSavingNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/StatefulNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/StylesheetDeletingNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Notifications/StylesheetSavingNotification.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Models/DeepCloneHelper.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Models/File.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Models/PropertyGroupExtensions.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Core/Models/PropertyGroupExtensions.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Fix based on review * Fix after merge Signed-off-by: Zeegaan <nge@umbraco.dk> Co-authored-by: Nikolaj Geisle <niko737@edu.ucl.dk> Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> Co-authored-by: Zeegaan <nge@umbraco.dk>
This commit is contained in:
@@ -1,7 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Schema;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Umbraco.Cms.Core.Configuration.Models;
|
||||
using Umbraco.Cms.Core.Dictionary;
|
||||
@@ -12,286 +8,285 @@ using Umbraco.Cms.Core.Security;
|
||||
using Umbraco.Cms.Core.Services;
|
||||
using Umbraco.Extensions;
|
||||
|
||||
namespace Umbraco.Cms.Core.Models.Mapping
|
||||
namespace Umbraco.Cms.Core.Models.Mapping;
|
||||
|
||||
/// <summary>
|
||||
/// A custom tab/property resolver for members which will ensure that the built-in membership properties are or aren't displayed
|
||||
/// depending on if the member type has these properties
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This also ensures that the IsLocked out property is readonly when the member is not locked out - this is because
|
||||
/// an admin cannot actually set isLockedOut = true, they can only unlock.
|
||||
/// </remarks>
|
||||
public class MemberTabsAndPropertiesMapper : TabsAndPropertiesMapper<IMember>
|
||||
{
|
||||
/// <summary>
|
||||
/// A custom tab/property resolver for members which will ensure that the built-in membership properties are or aren't displayed
|
||||
/// depending on if the member type has these properties
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This also ensures that the IsLocked out property is readonly when the member is not locked out - this is because
|
||||
/// an admin cannot actually set isLockedOut = true, they can only unlock.
|
||||
/// </remarks>
|
||||
public class MemberTabsAndPropertiesMapper : TabsAndPropertiesMapper<IMember>
|
||||
private readonly IBackOfficeSecurityAccessor _backofficeSecurityAccessor;
|
||||
private readonly ILocalizedTextService _localizedTextService;
|
||||
private readonly IMemberTypeService _memberTypeService;
|
||||
private readonly IMemberService _memberService;
|
||||
private readonly IMemberGroupService _memberGroupService;
|
||||
private readonly MemberPasswordConfigurationSettings _memberPasswordConfiguration;
|
||||
private readonly PropertyEditorCollection _propertyEditorCollection;
|
||||
|
||||
public MemberTabsAndPropertiesMapper(
|
||||
ICultureDictionary cultureDictionary,
|
||||
IBackOfficeSecurityAccessor backofficeSecurityAccessor,
|
||||
ILocalizedTextService localizedTextService,
|
||||
IMemberTypeService memberTypeService,
|
||||
IMemberService memberService,
|
||||
IMemberGroupService memberGroupService,
|
||||
IOptions<MemberPasswordConfigurationSettings> memberPasswordConfiguration,
|
||||
IContentTypeBaseServiceProvider contentTypeBaseServiceProvider,
|
||||
PropertyEditorCollection propertyEditorCollection)
|
||||
: base(cultureDictionary, localizedTextService, contentTypeBaseServiceProvider)
|
||||
{
|
||||
private readonly IBackOfficeSecurityAccessor _backofficeSecurityAccessor;
|
||||
private readonly ILocalizedTextService _localizedTextService;
|
||||
private readonly IMemberTypeService _memberTypeService;
|
||||
private readonly IMemberService _memberService;
|
||||
private readonly IMemberGroupService _memberGroupService;
|
||||
private readonly MemberPasswordConfigurationSettings _memberPasswordConfiguration;
|
||||
private readonly PropertyEditorCollection _propertyEditorCollection;
|
||||
_backofficeSecurityAccessor = backofficeSecurityAccessor ?? throw new ArgumentNullException(nameof(backofficeSecurityAccessor));
|
||||
_localizedTextService = localizedTextService ?? throw new ArgumentNullException(nameof(localizedTextService));
|
||||
_memberTypeService = memberTypeService ?? throw new ArgumentNullException(nameof(memberTypeService));
|
||||
_memberService = memberService ?? throw new ArgumentNullException(nameof(memberService));
|
||||
_memberGroupService = memberGroupService ?? throw new ArgumentNullException(nameof(memberGroupService));
|
||||
_memberPasswordConfiguration = memberPasswordConfiguration.Value;
|
||||
_propertyEditorCollection = propertyEditorCollection;
|
||||
}
|
||||
|
||||
public MemberTabsAndPropertiesMapper(ICultureDictionary cultureDictionary,
|
||||
IBackOfficeSecurityAccessor backofficeSecurityAccessor,
|
||||
ILocalizedTextService localizedTextService,
|
||||
IMemberTypeService memberTypeService,
|
||||
IMemberService memberService,
|
||||
IMemberGroupService memberGroupService,
|
||||
IOptions<MemberPasswordConfigurationSettings> memberPasswordConfiguration,
|
||||
IContentTypeBaseServiceProvider contentTypeBaseServiceProvider,
|
||||
PropertyEditorCollection propertyEditorCollection)
|
||||
: base(cultureDictionary, localizedTextService, contentTypeBaseServiceProvider)
|
||||
/// <inheritdoc />
|
||||
/// <remarks>Overridden to deal with custom member properties and permissions.</remarks>
|
||||
public override IEnumerable<Tab<ContentPropertyDisplay>> Map(IMember source, MapperContext context)
|
||||
{
|
||||
|
||||
IMemberType? memberType = _memberTypeService.Get(source.ContentTypeId);
|
||||
|
||||
if (memberType is not null)
|
||||
{
|
||||
_backofficeSecurityAccessor = backofficeSecurityAccessor ?? throw new ArgumentNullException(nameof(backofficeSecurityAccessor));
|
||||
_localizedTextService = localizedTextService ?? throw new ArgumentNullException(nameof(localizedTextService));
|
||||
_memberTypeService = memberTypeService ?? throw new ArgumentNullException(nameof(memberTypeService));
|
||||
_memberService = memberService ?? throw new ArgumentNullException(nameof(memberService));
|
||||
_memberGroupService = memberGroupService ?? throw new ArgumentNullException(nameof(memberGroupService));
|
||||
_memberPasswordConfiguration = memberPasswordConfiguration.Value;
|
||||
_propertyEditorCollection = propertyEditorCollection;
|
||||
|
||||
IgnoreProperties = memberType.CompositionPropertyTypes
|
||||
.Where(x => x.HasIdentity == false)
|
||||
.Select(x => x.Alias)
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <remarks>Overridden to deal with custom member properties and permissions.</remarks>
|
||||
public override IEnumerable<Tab<ContentPropertyDisplay>> Map(IMember source, MapperContext context)
|
||||
IEnumerable<Tab<ContentPropertyDisplay>> resolved = base.Map(source, context);
|
||||
|
||||
return resolved;
|
||||
}
|
||||
|
||||
[Obsolete("Use MapMembershipProperties. Will be removed in Umbraco 10.")]
|
||||
protected override IEnumerable<ContentPropertyDisplay> GetCustomGenericProperties(IContentBase content)
|
||||
{
|
||||
var member = (IMember)content;
|
||||
return MapMembershipProperties(member, null);
|
||||
}
|
||||
|
||||
private Dictionary<string, object> GetPasswordConfig(IMember member)
|
||||
{
|
||||
var result = new Dictionary<string, object>(_memberPasswordConfiguration.GetConfiguration(true))
|
||||
{
|
||||
// the password change toggle will only be displayed if there is already a password assigned.
|
||||
{"hasPassword", member.RawPasswordValue.IsNullOrWhiteSpace() == false}
|
||||
};
|
||||
|
||||
var memberType = _memberTypeService.Get(source.ContentTypeId);
|
||||
// This will always be true for members since we always want to allow admins to change a password - so long as that
|
||||
// user has access to edit members (but that security is taken care of separately)
|
||||
result["allowManuallyChangingPassword"] = true;
|
||||
|
||||
if (memberType is not null)
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overridden to assign the IsSensitive property values
|
||||
/// </summary>
|
||||
/// <param name="content"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="context"></param>
|
||||
/// <returns></returns>
|
||||
protected override List<ContentPropertyDisplay> MapProperties(IContentBase content, List<IProperty> properties, MapperContext context)
|
||||
{
|
||||
List<ContentPropertyDisplay> result = base.MapProperties(content, properties, context);
|
||||
var member = (IMember)content;
|
||||
IMemberType? memberType = _memberTypeService.Get(member.ContentTypeId);
|
||||
|
||||
// now update the IsSensitive value
|
||||
foreach (ContentPropertyDisplay prop in result)
|
||||
{
|
||||
// check if this property is flagged as sensitive
|
||||
var isSensitiveProperty = memberType?.IsSensitiveProperty(prop.Alias) ?? false;
|
||||
// check permissions for viewing sensitive data
|
||||
if (isSensitiveProperty && _backofficeSecurityAccessor.BackOfficeSecurity?.CurrentUser?.HasAccessToSensitiveData() == false)
|
||||
{
|
||||
|
||||
IgnoreProperties = memberType.CompositionPropertyTypes
|
||||
.Where(x => x.HasIdentity == false)
|
||||
.Select(x => x.Alias)
|
||||
.ToArray();
|
||||
// mark this property as sensitive
|
||||
prop.IsSensitive = true;
|
||||
// mark this property as readonly so that it does not post any data
|
||||
prop.Readonly = true;
|
||||
// replace this editor with a sensitive value
|
||||
prop.View = "sensitivevalue";
|
||||
// clear the value
|
||||
prop.Value = null;
|
||||
}
|
||||
|
||||
var resolved = base.Map(source, context);
|
||||
|
||||
return resolved;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
[Obsolete("Use MapMembershipProperties. Will be removed in Umbraco 10.")]
|
||||
protected override IEnumerable<ContentPropertyDisplay> GetCustomGenericProperties(IContentBase content)
|
||||
/// <summary>
|
||||
/// Returns the login property display field
|
||||
/// </summary>
|
||||
/// <param name="member"></param>
|
||||
/// <param name="localizedText"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
/// If the membership provider installed is the umbraco membership provider, then we will allow changing the username, however if
|
||||
/// the membership provider is a custom one, we cannot allow changing the username because MembershipProvider's do not actually natively
|
||||
/// allow that.
|
||||
/// </remarks>
|
||||
internal static ContentPropertyDisplay GetLoginProperty(IMember member, ILocalizedTextService localizedText)
|
||||
{
|
||||
var prop = new ContentPropertyDisplay
|
||||
{
|
||||
var member = (IMember)content;
|
||||
return MapMembershipProperties(member, null);
|
||||
}
|
||||
Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}login",
|
||||
Label = localizedText.Localize(null,"login"),
|
||||
Value = member.Username
|
||||
};
|
||||
|
||||
private Dictionary<string, object> GetPasswordConfig(IMember member)
|
||||
prop.View = "textbox";
|
||||
prop.Validation.Mandatory = true;
|
||||
return prop;
|
||||
}
|
||||
|
||||
internal IDictionary<string, bool> GetMemberGroupValue(string username)
|
||||
{
|
||||
IEnumerable<string> userRoles = _memberService.GetAllRoles(username);
|
||||
|
||||
// create a dictionary of all roles (except internal roles) + "false"
|
||||
var result = _memberGroupService.GetAll()
|
||||
.Select(x => x.Name!)
|
||||
// if a role starts with __umbracoRole we won't show it as it's an internal role used for public access
|
||||
.Where(x => x?.StartsWith(Constants.Conventions.Member.InternalRolePrefix) == false)
|
||||
.OrderBy(x => x, StringComparer.OrdinalIgnoreCase)
|
||||
.ToDictionary(x => x, x => false);
|
||||
|
||||
// if user has no roles, just return the dictionary
|
||||
if (userRoles == null)
|
||||
{
|
||||
var result = new Dictionary<string, object>(_memberPasswordConfiguration.GetConfiguration(true))
|
||||
{
|
||||
// the password change toggle will only be displayed if there is already a password assigned.
|
||||
{"hasPassword", member.RawPasswordValue.IsNullOrWhiteSpace() == false}
|
||||
};
|
||||
|
||||
// This will always be true for members since we always want to allow admins to change a password - so long as that
|
||||
// user has access to edit members (but that security is taken care of separately)
|
||||
result["allowManuallyChangingPassword"] = true;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overridden to assign the IsSensitive property values
|
||||
/// </summary>
|
||||
/// <param name="content"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="context"></param>
|
||||
/// <returns></returns>
|
||||
protected override List<ContentPropertyDisplay> MapProperties(IContentBase content, List<IProperty> properties, MapperContext context)
|
||||
// else update the dictionary to "true" for the user roles (except internal roles)
|
||||
foreach (var userRole in userRoles.Where(x => x?.StartsWith(Constants.Conventions.Member.InternalRolePrefix) == false))
|
||||
{
|
||||
var result = base.MapProperties(content, properties, context);
|
||||
var member = (IMember)content;
|
||||
var memberType = _memberTypeService.Get(member.ContentTypeId);
|
||||
result[userRole] = true;
|
||||
}
|
||||
|
||||
// now update the IsSensitive value
|
||||
foreach (var prop in result)
|
||||
return result;
|
||||
}
|
||||
|
||||
public IEnumerable<ContentPropertyDisplay> MapMembershipProperties(IMember member, MapperContext? context)
|
||||
{
|
||||
var properties = new List<ContentPropertyDisplay>
|
||||
{
|
||||
GetLoginProperty(member, _localizedTextService),
|
||||
new()
|
||||
{
|
||||
// check if this property is flagged as sensitive
|
||||
var isSensitiveProperty = memberType?.IsSensitiveProperty(prop.Alias) ?? false;
|
||||
// check permissions for viewing sensitive data
|
||||
if (isSensitiveProperty && (_backofficeSecurityAccessor.BackOfficeSecurity?.CurrentUser?.HasAccessToSensitiveData() == false))
|
||||
Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}email",
|
||||
Label = _localizedTextService.Localize("general","email"),
|
||||
Value = member.Email,
|
||||
View = "email",
|
||||
Validation = { Mandatory = true }
|
||||
},
|
||||
new()
|
||||
{
|
||||
Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}password",
|
||||
Label = _localizedTextService.Localize(null,"password"),
|
||||
Value = new Dictionary<string, object?>
|
||||
{
|
||||
// mark this property as sensitive
|
||||
prop.IsSensitive = true;
|
||||
// mark this property as readonly so that it does not post any data
|
||||
prop.Readonly = true;
|
||||
// replace this editor with a sensitive value
|
||||
prop.View = "sensitivevalue";
|
||||
// clear the value
|
||||
prop.Value = null;
|
||||
// TODO: why ignoreCase, what are we doing here?!
|
||||
{ "newPassword", member.GetAdditionalDataValueIgnoreCase("NewPassword", null) }
|
||||
},
|
||||
View = "changepassword",
|
||||
Config = GetPasswordConfig(member) // Initialize the dictionary with the configuration from the default membership provider
|
||||
},
|
||||
new()
|
||||
{
|
||||
Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}membergroup",
|
||||
Label = _localizedTextService.Localize("content","membergroup"),
|
||||
Value = GetMemberGroupValue(member.Username),
|
||||
View = "membergroups",
|
||||
Config = new Dictionary<string, object>
|
||||
{
|
||||
{ "IsRequired", true }
|
||||
},
|
||||
},
|
||||
|
||||
// These properties used to live on the member as property data, defaulting to sensitive, so we set them to sensitive here too
|
||||
new()
|
||||
{
|
||||
Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}failedPasswordAttempts",
|
||||
Label = _localizedTextService.Localize("user", "failedPasswordAttempts"),
|
||||
Value = member.FailedPasswordAttempts,
|
||||
View = "readonlyvalue",
|
||||
IsSensitive = true,
|
||||
},
|
||||
|
||||
new()
|
||||
{
|
||||
Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}approved",
|
||||
Label = _localizedTextService.Localize("user", "stateApproved"),
|
||||
Value = member.IsApproved,
|
||||
View = "boolean",
|
||||
IsSensitive = true,
|
||||
Readonly = false,
|
||||
},
|
||||
|
||||
new()
|
||||
{
|
||||
Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}lockedOut",
|
||||
Label = _localizedTextService.Localize("user", "stateLockedOut"),
|
||||
Value = member.IsLockedOut,
|
||||
View = "boolean",
|
||||
IsSensitive = true,
|
||||
Readonly = !member.IsLockedOut, // IMember.IsLockedOut can't be set to true, so make it readonly when that's the case (you can only unlock)
|
||||
},
|
||||
|
||||
new()
|
||||
{
|
||||
Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}lastLockoutDate",
|
||||
Label = _localizedTextService.Localize("user", "lastLockoutDate"),
|
||||
Value = member.LastLockoutDate?.ToString(),
|
||||
View = "readonlyvalue",
|
||||
IsSensitive = true,
|
||||
},
|
||||
|
||||
new()
|
||||
{
|
||||
Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}lastLoginDate",
|
||||
Label = _localizedTextService.Localize("user", "lastLogin"),
|
||||
Value = member.LastLoginDate?.ToString(),
|
||||
View = "readonlyvalue",
|
||||
IsSensitive = true,
|
||||
},
|
||||
|
||||
new()
|
||||
{
|
||||
Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}lastPasswordChangeDate",
|
||||
Label = _localizedTextService.Localize("user", "lastPasswordChangeDate"),
|
||||
Value = member.LastPasswordChangeDate?.ToString(),
|
||||
View = "readonlyvalue",
|
||||
IsSensitive = true,
|
||||
},
|
||||
};
|
||||
|
||||
if (_backofficeSecurityAccessor.BackOfficeSecurity?.CurrentUser?.HasAccessToSensitiveData() is false)
|
||||
{
|
||||
// Current user doesn't have access to sensitive data so explicitly set the views and remove the value from sensitive data
|
||||
foreach (ContentPropertyDisplay property in properties)
|
||||
{
|
||||
if (property.IsSensitive)
|
||||
{
|
||||
property.Value = null;
|
||||
property.View = "sensitivevalue";
|
||||
property.Readonly = true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the login property display field
|
||||
/// </summary>
|
||||
/// <param name="member"></param>
|
||||
/// <param name="display"></param>
|
||||
/// <param name="localizedText"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
/// If the membership provider installed is the umbraco membership provider, then we will allow changing the username, however if
|
||||
/// the membership provider is a custom one, we cannot allow changing the username because MembershipProvider's do not actually natively
|
||||
/// allow that.
|
||||
/// </remarks>
|
||||
internal static ContentPropertyDisplay GetLoginProperty(IMember member, ILocalizedTextService localizedText)
|
||||
{
|
||||
var prop = new ContentPropertyDisplay
|
||||
{
|
||||
Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}login",
|
||||
Label = localizedText.Localize(null,"login"),
|
||||
Value = member.Username
|
||||
};
|
||||
|
||||
prop.View = "textbox";
|
||||
prop.Validation.Mandatory = true;
|
||||
return prop;
|
||||
}
|
||||
|
||||
internal IDictionary<string, bool> GetMemberGroupValue(string username)
|
||||
{
|
||||
IEnumerable<string> userRoles = _memberService.GetAllRoles(username);
|
||||
|
||||
// create a dictionary of all roles (except internal roles) + "false"
|
||||
var result = _memberGroupService.GetAll()
|
||||
.Select(x => x.Name!)
|
||||
// if a role starts with __umbracoRole we won't show it as it's an internal role used for public access
|
||||
.Where(x => x?.StartsWith(Constants.Conventions.Member.InternalRolePrefix) == false)
|
||||
.OrderBy(x => x, StringComparer.OrdinalIgnoreCase)
|
||||
.ToDictionary(x => x, x => false);
|
||||
|
||||
// if user has no roles, just return the dictionary
|
||||
if (userRoles == null)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
// else update the dictionary to "true" for the user roles (except internal roles)
|
||||
foreach (var userRole in userRoles.Where(x => x?.StartsWith(Constants.Conventions.Member.InternalRolePrefix) == false))
|
||||
{
|
||||
result[userRole] = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public IEnumerable<ContentPropertyDisplay> MapMembershipProperties(IMember member, MapperContext? context)
|
||||
{
|
||||
var properties = new List<ContentPropertyDisplay>
|
||||
{
|
||||
GetLoginProperty(member, _localizedTextService),
|
||||
new()
|
||||
{
|
||||
Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}email",
|
||||
Label = _localizedTextService.Localize("general","email"),
|
||||
Value = member.Email,
|
||||
View = "email",
|
||||
Validation = { Mandatory = true }
|
||||
},
|
||||
new()
|
||||
{
|
||||
Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}password",
|
||||
Label = _localizedTextService.Localize(null,"password"),
|
||||
Value = new Dictionary<string, object?>
|
||||
{
|
||||
// TODO: why ignoreCase, what are we doing here?!
|
||||
{ "newPassword", member.GetAdditionalDataValueIgnoreCase("NewPassword", null) }
|
||||
},
|
||||
View = "changepassword",
|
||||
Config = GetPasswordConfig(member) // Initialize the dictionary with the configuration from the default membership provider
|
||||
},
|
||||
new()
|
||||
{
|
||||
Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}membergroup",
|
||||
Label = _localizedTextService.Localize("content","membergroup"),
|
||||
Value = GetMemberGroupValue(member.Username),
|
||||
View = "membergroups",
|
||||
Config = new Dictionary<string, object>
|
||||
{
|
||||
{ "IsRequired", true }
|
||||
},
|
||||
},
|
||||
|
||||
// These properties used to live on the member as property data, defaulting to sensitive, so we set them to sensitive here too
|
||||
new()
|
||||
{
|
||||
Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}failedPasswordAttempts",
|
||||
Label = _localizedTextService.Localize("user", "failedPasswordAttempts"),
|
||||
Value = member.FailedPasswordAttempts,
|
||||
View = "readonlyvalue",
|
||||
IsSensitive = true,
|
||||
},
|
||||
|
||||
new()
|
||||
{
|
||||
Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}approved",
|
||||
Label = _localizedTextService.Localize("user", "stateApproved"),
|
||||
Value = member.IsApproved,
|
||||
View = "boolean",
|
||||
IsSensitive = true,
|
||||
Readonly = false,
|
||||
},
|
||||
|
||||
new()
|
||||
{
|
||||
Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}lockedOut",
|
||||
Label = _localizedTextService.Localize("user", "stateLockedOut"),
|
||||
Value = member.IsLockedOut,
|
||||
View = "boolean",
|
||||
IsSensitive = true,
|
||||
Readonly = !member.IsLockedOut, // IMember.IsLockedOut can't be set to true, so make it readonly when that's the case (you can only unlock)
|
||||
},
|
||||
|
||||
new()
|
||||
{
|
||||
Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}lastLockoutDate",
|
||||
Label = _localizedTextService.Localize("user", "lastLockoutDate"),
|
||||
Value = member.LastLockoutDate?.ToString(),
|
||||
View = "readonlyvalue",
|
||||
IsSensitive = true,
|
||||
},
|
||||
|
||||
new()
|
||||
{
|
||||
Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}lastLoginDate",
|
||||
Label = _localizedTextService.Localize("user", "lastLogin"),
|
||||
Value = member.LastLoginDate?.ToString(),
|
||||
View = "readonlyvalue",
|
||||
IsSensitive = true,
|
||||
},
|
||||
|
||||
new()
|
||||
{
|
||||
Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}lastPasswordChangeDate",
|
||||
Label = _localizedTextService.Localize("user", "lastPasswordChangeDate"),
|
||||
Value = member.LastPasswordChangeDate?.ToString(),
|
||||
View = "readonlyvalue",
|
||||
IsSensitive = true,
|
||||
},
|
||||
};
|
||||
|
||||
if (_backofficeSecurityAccessor.BackOfficeSecurity?.CurrentUser?.HasAccessToSensitiveData() is false)
|
||||
{
|
||||
// Current user doesn't have access to sensitive data so explicitly set the views and remove the value from sensitive data
|
||||
foreach (var property in properties)
|
||||
{
|
||||
if (property.IsSensitive)
|
||||
{
|
||||
property.Value = null;
|
||||
property.View = "sensitivevalue";
|
||||
property.Readonly = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return properties;
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user