diff --git a/src/Umbraco.Core/Models/Mapping/MemberTabsAndPropertiesMapper.cs b/src/Umbraco.Core/Models/Mapping/MemberTabsAndPropertiesMapper.cs
index 02ee4fe744..0d3a5b7536 100644
--- a/src/Umbraco.Core/Models/Mapping/MemberTabsAndPropertiesMapper.cs
+++ b/src/Umbraco.Core/Models/Mapping/MemberTabsAndPropertiesMapper.cs
@@ -119,7 +119,7 @@ namespace Umbraco.Cms.Core.Models.Mapping
Value = _localizedTextService.UmbracoDictionaryTranslate(CultureDictionary, member.ContentType.Name),
View = _propertyEditorCollection[Constants.PropertyEditors.Aliases.Label].GetValueEditor().View
},
- GetLoginProperty(_memberTypeService, member, _localizedTextService),
+ GetLoginProperty(member, _localizedTextService),
new ContentPropertyDisplay
{
Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}email",
@@ -208,7 +208,6 @@ namespace Umbraco.Cms.Core.Models.Mapping
///
/// Returns the login property display field
///
- ///
///
///
///
@@ -218,7 +217,7 @@ namespace Umbraco.Cms.Core.Models.Mapping
/// the membership provider is a custom one, we cannot allow changing the username because MembershipProvider's do not actually natively
/// allow that.
///
- internal static ContentPropertyDisplay GetLoginProperty(IMemberTypeService memberTypeService, IMember member, ILocalizedTextService localizedText)
+ internal static ContentPropertyDisplay GetLoginProperty(IMember member, ILocalizedTextService localizedText)
{
var prop = new ContentPropertyDisplay
{
@@ -234,10 +233,9 @@ namespace Umbraco.Cms.Core.Models.Mapping
internal IDictionary GetMemberGroupValue(string username)
{
- var userRoles = username.IsNullOrWhiteSpace() ? null : _memberService.GetAllRoles(username);
+ IEnumerable userRoles = username.IsNullOrWhiteSpace() ? null : _memberService.GetAllRoles(username);
// create a dictionary of all roles (except internal roles) + "false"
- //TODO: use member role manager instead
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
@@ -246,11 +244,16 @@ namespace Umbraco.Cms.Core.Models.Mapping
.ToDictionary(x => x, x => false);
// if user has no roles, just return the dictionary
- if (userRoles == null) return result;
+ 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;
}
diff --git a/src/Umbraco.Infrastructure/Security/MemberUserStore.cs b/src/Umbraco.Infrastructure/Security/MemberUserStore.cs
index 2f2127201d..c0b9a19ef1 100644
--- a/src/Umbraco.Infrastructure/Security/MemberUserStore.cs
+++ b/src/Umbraco.Infrastructure/Security/MemberUserStore.cs
@@ -363,13 +363,6 @@ namespace Umbraco.Cms.Core.Security
cancellationToken.ThrowIfCancellationRequested();
ThrowIfDisposed();
- MemberIdentityUser user = await FindUserAsync(userId, cancellationToken);
- if (user == null)
- {
- //TODO: error throw or null result?
- return await Task.FromResult((IdentityUserLogin)null);
- }
-
if (string.IsNullOrWhiteSpace(loginProvider))
{
throw new ArgumentNullException(nameof(loginProvider));
@@ -380,11 +373,16 @@ namespace Umbraco.Cms.Core.Security
throw new ArgumentNullException(nameof(providerKey));
}
+ MemberIdentityUser user = await FindUserAsync(userId, cancellationToken);
+ if (user == null)
+ {
+ return await Task.FromResult((IdentityUserLogin)null);
+ }
+
IList logins = await GetLoginsAsync(user, cancellationToken);
UserLoginInfo found = logins.FirstOrDefault(x => x.ProviderKey == providerKey && x.LoginProvider == loginProvider);
if (found == null)
{
- //TODO: error throw or null result?
return await Task.FromResult((IdentityUserLogin)null);
}
diff --git a/src/Umbraco.Web.BackOffice/Mapping/MemberMapDefinition.cs b/src/Umbraco.Web.BackOffice/Mapping/MemberMapDefinition.cs
index 7ee456a323..be713ddfa9 100644
--- a/src/Umbraco.Web.BackOffice/Mapping/MemberMapDefinition.cs
+++ b/src/Umbraco.Web.BackOffice/Mapping/MemberMapDefinition.cs
@@ -35,7 +35,6 @@ namespace Umbraco.Cms.Web.BackOffice.Mapping
mapper.Define((source, context) => new MemberDisplay(), Map);
mapper.Define((source, context) => new MemberBasic(), Map);
mapper.Define((source, context) => new MemberGroupDisplay(), Map);
- mapper.Define((source, context) => new MemberGroupDisplay(), Map);
mapper.Define((source, context) => new ContentPropertyCollectionDto(), Map);
}
@@ -103,18 +102,5 @@ namespace Umbraco.Cms.Web.BackOffice.Mapping
{
target.Properties = context.MapEnumerable(source.Properties);
}
-
- ///
- /// Maps an identity role to a member group display
- ///
- ///
- ///
- ///
- private void Map(IdentityRole source, MemberGroupDisplay target, MapperContext context)
- {
- //TODO: this is all that is mapped at this time, we're losing a lot of properties
- target.Id = source.Id;
- target.Name = source.Name;
- }
}
}
diff --git a/src/Umbraco.Web.BackOffice/Trees/MemberGroupTreeController.cs b/src/Umbraco.Web.BackOffice/Trees/MemberGroupTreeController.cs
index 5888068656..0559a17a53 100644
--- a/src/Umbraco.Web.BackOffice/Trees/MemberGroupTreeController.cs
+++ b/src/Umbraco.Web.BackOffice/Trees/MemberGroupTreeController.cs
@@ -28,29 +28,23 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
IMemberGroupService memberGroupService,
IEventAggregator eventAggregator)
: base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory, eventAggregator)
- {
- _memberGroupService = memberGroupService;
- }
+ => _memberGroupService = memberGroupService;
- //TODO: change to role store
protected override IEnumerable GetTreeNodesFromService(string id, FormCollection queryStrings)
- {
- return _memberGroupService.GetAll()
+ => _memberGroupService.GetAll()
.OrderBy(x => x.Name)
.Select(dt => CreateTreeNode(dt.Id.ToString(), id, queryStrings, dt.Name, Constants.Icons.MemberGroup, false));
- }
protected override ActionResult CreateRootNode(FormCollection queryStrings)
{
- var rootResult = base.CreateRootNode(queryStrings);
+ ActionResult rootResult = base.CreateRootNode(queryStrings);
if (!(rootResult.Result is null))
{
return rootResult;
}
- var root = rootResult.Value;
+ TreeNode root = rootResult.Value;
//check if there are any groups
- //TODO: change to role store
root.HasChildren = _memberGroupService.GetAll().Any();
return root;
}