How to set validation email token expiration in asp.net core mvc
2 answers
Maybe this will help someone =)
Just do the following:
public void ConfigureServices(IServiceCollection services)
{
// ...
services.Configure<DataProtectionTokenProviderOptions>(options =>
{
options.TokenLifespan = TimeSpan.FromSeconds(1); // .FromDays(1) ...
});
}
This works for me.
+4
source to share
The next code change in the Create method (in the App_Start \ IdentityConfig.cs file) sets the tokens to expire after 3 hours.
if (dataProtectionProvider != null)
{
manager.UserTokenProvider =
new DataProtectorTokenProvider<ApplicationUser>
(dataProtectionProvider.Create("ASP.NET Identity"))
{
TokenLifespan = TimeSpan.FromHours(3)
};
}
Hope it helps.
0
source to share