abp
abp copied to clipboard
How to override IdentityUserManager?
https://github.com/abpframework/abp/blob/0.19.0/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserManager.cs
I need to override IdentityUserManager, but these code doesn't work:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Volo.Abp;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Services;
using Volo.Abp.Identity;
using Volo.Abp.Threading;
using VoloIdentityUserManager = Volo.Abp.Identity.IdentityUserManager;
namespace MyProject.Abp.Identity
{
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(VoloIdentityUserManager))]
public class IdentityUserManager : VoloIdentityUserManager
{
protected override CancellationToken CancellationToken => _cancellationTokenProvider.Token;
private readonly ICancellationTokenProvider _cancellationTokenProvider;
public IdentityUserManager(IdentityUserStore store, IOptions<IdentityOptions> optionsAccessor,
IPasswordHasher<IdentityUser> passwordHasher, IEnumerable<IUserValidator<IdentityUser>> userValidators,
IEnumerable<IPasswordValidator<IdentityUser>> passwordValidators, ILookupNormalizer keyNormalizer,
IdentityErrorDescriber errors, IServiceProvider services, ILogger<VoloIdentityUserManager> logger,
ICancellationTokenProvider cancellationTokenProvider) : base(store, optionsAccessor, passwordHasher,
userValidators, passwordValidators, keyNormalizer, errors, services, logger, cancellationTokenProvider)
{
_cancellationTokenProvider = cancellationTokenProvider;
}
public new async Task<IdentityResult> SetRolesAsync([NotNull] IdentityUser user, [NotNull] IEnumerable<string> roleNames)
{
throw new ApplicationException("Replace successful.");
}
}
}
Closed by https://github.com/abpframework/abp/commit/52513c9b986bd4e76129076ce845a80bf7b101a5
Does this issue fixed? I have the same question.

@abllyboy Replacing the controller may also have to deal with routing issues. Can you create a new issue?