I have an MVC 5 project that has been modified to use int as the primary key for identity as shown in this guide
I then enabled email confirmation as described in t
IUserTokenProvider by default is inserted by OWIN, but when you resolve UserManager from your DI container, component that provides IUserTokenProvider is not available and this component is not initialised.
You'll have to assign token provider to a global static variable when it is available and then re-use it in UserManager constructor:
public class AuthConfig
{
public static IDataProtectionProvider DataProtectionProvider { get; set; }
public void Configuration(IAppBuilder app)
{
ConfigureAuth(app);
}
public void ConfigureAuth(IAppBuilder app)
{
DataProtectionProvider = app.GetDataProtectionProvider();
// do other configuration
}
}
And in then re-assign it in constructor of UserManager constructor:
public UserManager(/*your dependecies*/)
{
var dataProtectorProvider = AuthConfig.DataProtectionProvider;
var dataProtector = dataProtectorProvider.Create("My Asp.Net Identity");
this.UserTokenProvider = new DataProtectorTokenProvider<ApplicationUser, Guid>(dataProtector)
{
TokenLifespan = TimeSpan.FromHours(24),
};
// other stuff
}