Hi ABP Support Team,
I am using ABP Blazor Web App version 9.1.0 with PostgreSQL and EF Core. I want to implement the "force password change on next login" flow using ResetPasswordAsync and GeneratePasswordResetTokenAsync from IdentityUserManager. However, I always get the following error when calling these methods:
System.NotSupportedException: 'No IUserTwoFactorTokenProvider<TUser> named 'Default' is registered.'
My configuration in CoreBackendHttpApiHostModule.cs:
context.Services.AddIdentity<IdentityUser, IdentityRole>() .AddEntityFrameworkStores<CoreBackendDbContext>() .AddDefaultTokenProviders();
I have installed Microsoft.AspNetCore.Identity.EntityFrameworkCore. My CoreBackendDbContext inherits from AbpDbContext<CoreBackendDbContext>. I do not have any custom User or Role classes, I am using the default IdentityUser and IdentityRole. I have cleaned and rebuilt the solution, but the error persists. The code that causes the error:
var result = await _userManager.ResetPasswordAsync(user, input.ChangePasswordToken, input.NewPassword);
What I have tried: Adding correct using statements. Ensuring only one call to AddIdentity<> exists. Registering DataProtectorTokenProvider<IdentityUser> manually – still doesn't work. Could you please advise what might be missing in my configuration, or if there is any ABP-specific requirement to enable the default token provider for password reset?
Thank you very much!
3 Answer(s)
-
0
context.Services.AddIdentity<IdentityUser, IdentityRole>() .AddEntityFrameworkStores<CoreBackendDbContext>() .AddDefaultTokenProviders();
Hi, you don't need to add this configuration, if your project depends on the
Volo.Abp.Identity.Pro.Domain
project, then there is a similar configuration is already made on the module side. So, you can remove this configuration. Probably, it's causing this problem because it overrides the default registration:context.Services.AddIdentityCore<IdentityUser>().AddTokenProvider(TokenOptions.DefaultAuthenticatorProvider, typeof(AbpAuthenticatorTokenProvider));
Therefore, can you please remove the related configuration in your side, and check if it fixes the problem or not?
-
0
-
0
[DuHK] said: I deleted the above configuration but when I run it again, I still get this error. Give me an example so that when a user changes their password the first time they log in, the token is returned.
Your module need to depend on
AbpIdentityAspNetCoreModule
or you should add the following configuration:public override void PreConfigureServices(ServiceConfigurationContext context) { PreConfigure<IdentityBuilder>(builder => { builder.AddDefaultTokenProviders() }); }
See https://github.com/abpframework/abp/issues/9009#issuecomment-841082012 for more information.