Merge remote-tracking branch 'origin/netcore/dev' into netcore/feature/align-infrastructure-namespaces
# Conflicts: # src/Umbraco.Infrastructure/Cache/DistributedCacheBinder_Handlers.cs # src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.MappingProfiles.cs # src/Umbraco.Infrastructure/PropertyEditors/PropertyEditorsComponent.cs # src/Umbraco.Infrastructure/Security/BackOfficeClaimsPrincipalFactory.cs # src/Umbraco.Infrastructure/Security/IBackOfficeUserManager.cs # src/Umbraco.Infrastructure/Security/IUmbracoUserManager.cs # src/Umbraco.Infrastructure/Security/SignOutAuditEventArgs.cs # src/Umbraco.Infrastructure/Security/UmbracoUserManager.cs # src/Umbraco.Infrastructure/Security/UserInviteEventArgs.cs # src/Umbraco.Tests.UnitTests/AutoFixture/AutoMoqDataAttribute.cs # src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/BackOffice/BackOfficeLookupNormalizerTests.cs # src/Umbraco.Web.BackOffice/Controllers/MemberController.cs # src/Umbraco.Web/Security/IBackOfficeUserPasswordChecker.cs # src/Umbraco.Web/Security/Providers/MembersRoleProvider.cs
This commit is contained in:
@@ -26,13 +26,12 @@ namespace Umbraco.Cms.Web.Common.Security
|
||||
IPasswordHasher<BackOfficeIdentityUser> passwordHasher,
|
||||
IEnumerable<IUserValidator<BackOfficeIdentityUser>> userValidators,
|
||||
IEnumerable<IPasswordValidator<BackOfficeIdentityUser>> passwordValidators,
|
||||
BackOfficeLookupNormalizer keyNormalizer,
|
||||
BackOfficeIdentityErrorDescriber errors,
|
||||
IServiceProvider services,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
ILogger<UserManager<BackOfficeIdentityUser>> logger,
|
||||
IOptions<UserPasswordConfigurationSettings> passwordConfiguration)
|
||||
: base(ipResolver, store, optionsAccessor, passwordHasher, userValidators, passwordValidators, keyNormalizer, errors, services, logger, passwordConfiguration)
|
||||
: base(ipResolver, store, optionsAccessor, passwordHasher, userValidators, passwordValidators, errors, services, logger, passwordConfiguration)
|
||||
{
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
@@ -136,7 +135,7 @@ namespace Umbraco.Cms.Web.Common.Security
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override async Task<IdentityResult> SetLockoutEndDateAsync(BackOfficeIdentityUser user, DateTimeOffset? lockoutEnd)
|
||||
{
|
||||
|
||||
66
src/Umbraco.Web.Common/Security/MemberManager.cs
Normal file
66
src/Umbraco.Web.Common/Security/MemberManager.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Principal;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Umbraco.Cms.Core.Configuration.Models;
|
||||
using Umbraco.Cms.Core.Models.ContentEditing;
|
||||
using Umbraco.Cms.Core.Models.Membership;
|
||||
using Umbraco.Cms.Core.Net;
|
||||
using Umbraco.Cms.Core.Security;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Extensions;
|
||||
|
||||
|
||||
namespace Umbraco.Web.Common.Security
|
||||
{
|
||||
public class MemberManager : UmbracoUserManager<MembersIdentityUser, MemberPasswordConfigurationSettings>, IMemberManager
|
||||
{
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
public MemberManager(
|
||||
IIpResolver ipResolver,
|
||||
IUserStore<MembersIdentityUser> store,
|
||||
IOptions<MembersIdentityOptions> optionsAccessor,
|
||||
IPasswordHasher<MembersIdentityUser> passwordHasher,
|
||||
IEnumerable<IUserValidator<MembersIdentityUser>> userValidators,
|
||||
IEnumerable<IPasswordValidator<MembersIdentityUser>> passwordValidators,
|
||||
BackOfficeIdentityErrorDescriber errors,
|
||||
IServiceProvider services,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
ILogger<UserManager<MembersIdentityUser>> logger,
|
||||
IOptions<MemberPasswordConfigurationSettings> passwordConfiguration)
|
||||
: base(ipResolver, store, optionsAccessor, passwordHasher, userValidators, passwordValidators, errors, services, logger, passwordConfiguration)
|
||||
{
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
private string GetCurrentUserId(IPrincipal currentUser)
|
||||
{
|
||||
UmbracoBackOfficeIdentity umbIdentity = currentUser?.GetUmbracoIdentity();
|
||||
var currentUserId = umbIdentity?.GetUserId<string>() ?? Cms.Core.Constants.Security.SuperUserIdAsString;
|
||||
return currentUserId;
|
||||
}
|
||||
|
||||
private IdentityAuditEventArgs CreateArgs(AuditEvent auditEvent, IPrincipal currentUser, string affectedUserId, string affectedUsername)
|
||||
{
|
||||
var currentUserId = GetCurrentUserId(currentUser);
|
||||
var ip = IpResolver.GetCurrentRequestIpAddress();
|
||||
return new IdentityAuditEventArgs(auditEvent, ip, currentUserId, string.Empty, affectedUserId, affectedUsername);
|
||||
}
|
||||
|
||||
//TODO: have removed all other member audit events - can revisit if we need member auditing on a user level in future
|
||||
|
||||
public void RaiseForgotPasswordRequestedEvent(IPrincipal currentUser, string userId) => throw new NotImplementedException();
|
||||
|
||||
public void RaiseForgotPasswordChangedSuccessEvent(IPrincipal currentUser, string userId) => throw new NotImplementedException();
|
||||
|
||||
public SignOutAuditEventArgs RaiseLogoutSuccessEvent(IPrincipal currentUser, string userId) => throw new NotImplementedException();
|
||||
|
||||
public UserInviteEventArgs RaiseSendingUserInvite(IPrincipal currentUser, UserInvite invite, IUser createdUser) => throw new NotImplementedException();
|
||||
|
||||
public bool HasSendingUserInviteEventHandler { get; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user