Password reset token provider in ASP.NET core - IUserTokenProvider not found

后端 未结 5 2469
时光说笑
时光说笑 2021-02-09 22:30

Hello,

I googled thoroughly but there is hundred examples from ASP.NET but nothing about ASP.NET Core.

In order to getting password reset work I need to registe

5条回答
  •  萌比男神i
    2021-02-09 22:58

    I'm not sure if it's workaround or normal approach, but the IUserTwoFactorTokenProvider interface seems to be a right way. IUserTokenProvider appears to no longer exists.

    Figured out that I have to register the provider manually in the identity:

    services.AddIdentity(options =>
                {
                    ...
                    options.Tokens.ProviderMap.Add("Default", new TokenProviderDescriptor(typeof(IUserTwoFactorTokenProvider)));
                })
    

    And the optional configuration in ConfigureServices:

    services.Configure(o =>
            {
                o.Name = "Default";
                o.TokenLifespan = TimeSpan.FromHours(1);
            });
    

    And the password reset / email validation tokens are working now.

    PS: Opened an issue for clarification

提交回复
热议问题