using System; using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Volo.Abp.Caching; using Volo.Abp.DependencyInjection; using Volo.Abp.EventBus.Distributed; using Volo.Abp.Identity; using Volo.Abp.Security.Claims; using Volo.Abp.Settings; using Volo.Abp.Threading; using IdentityUser = Volo.Abp.Identity.IdentityUser; namespace Sozsoft.Platform.Identity; [Dependency(ReplaceServices = true)] [ExposeServices(typeof(IdentityUserManager))] public class PlatformUserManager : IdentityUserManager { public PlatformUserManager( IdentityUserStore store, IIdentityRoleRepository roleRepository, IIdentityUserRepository userRepository, IOptions optionsAccessor, IPasswordHasher passwordHasher, IEnumerable> userValidators, IEnumerable> passwordValidators, ILookupNormalizer keyNormalizer, IdentityErrorDescriber errors, IServiceProvider services, ILogger logger, ICancellationTokenProvider cancellationTokenProvider, IOrganizationUnitRepository organizationUnitRepository, ISettingProvider settingProvider, IDistributedEventBus distributedEventBus, IIdentityLinkUserRepository identityLinkUserRepository, IDistributedCache dynamicClaimCache) : base(store, roleRepository, userRepository, optionsAccessor, passwordHasher, userValidators, passwordValidators, keyNormalizer, errors, services, logger, cancellationTokenProvider, organizationUnitRepository, settingProvider, distributedEventBus, identityLinkUserRepository, dynamicClaimCache) { } public override async Task AddPasswordAsync(IdentityUser user, string password) { var result = await base.AddPasswordAsync(user, password); if (result.Succeeded) await SetPasswordChangeDateAsync(user); return result; } public override async Task ChangePasswordAsync(IdentityUser user, string currentPassword, string newPassword) { var result = await base.ChangePasswordAsync(user, currentPassword, newPassword); if (result.Succeeded) await SetPasswordChangeDateAsync(user); return result; } public override async Task ResetPasswordAsync(IdentityUser user, string token, string newPassword) { var result = await base.ResetPasswordAsync(user, token, newPassword); if (result.Succeeded) await SetPasswordChangeDateAsync(user); return result; } public override async Task CreateAsync(IdentityUser user, string password) { var result = await base.CreateAsync(user, password); if (result.Succeeded) await SetPasswordChangeDateAsync(user); return result; } protected async Task SetPasswordChangeDateAsync(IdentityUser user) { user.SetLastPasswordChangeTime(new DateTimeOffset(user.LastModificationTime ?? user.CreationTime)); await UpdateUserAsync(user); } }