c# - ASP.NET Identity - can't register UserTokenProvider -


i have issue generating reset password token in asp.net core 1.0 project:

startup.cs

public void configureservices(iservicecollection services) {     ...     services.addidentity<userdb, groupdb>()             .adddefaulttokenproviders() } 

then in controller di:

... usermanager<userdb> usermanager ...   string token = await usermanager.generatepasswordresettokenasync(user); 

and

no iusertokenprovider named 'default' registered.

how fix ?

i can see there's no providers inside of userstore constructor:

enter image description here

i noticed userstore class didn't have iusertokenprovider interface implementation. also, in applicationusermanager class constructor, check if tokenproviderdescriptor registered

public class applicationusermanager : usermanager<userdb> {     public applicationusermanager(userstore store, ioptions<identityoptions> optionsaccessor, ipasswordhasher<userdb> passwordhasher, ienumerable<iuservalidator<userdb>> uservalidators, ienumerable<ipasswordvalidator<userdb>> passwordvalidators, ilookupnormalizer keynormalizer, identityerrordescriber errors, iserviceprovider services, ilogger<usermanager<userdb>> logger, ihttpcontextaccessor contextaccessor)          : base(store, optionsaccessor, passwordhasher, uservalidators, passwordvalidators, keynormalizer, errors, services, logger, contextaccessor)     {         if (!optionsaccessor.value.tokens.providermap.containskey("defaulttokenprovider"))             optionsaccessor.value.tokens.providermap.add("defaulttokenprovider", new tokenproviderdescriptor(typeof(userstore)));     } } 

that's solved issue. !


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -