Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP Identity Core GeneratePasswordResetTokenAsync expired

I have set up an Identity Server 4 project in .NET Core 2.1, I have everything working but when I use the user manager to generate the reset password token, the token expires after 24 hours, can I change this so it's 48 hours?

My code to send the reset token looks like this:

var code = await _userManager.GeneratePasswordResetTokenAsync(user);

var callbackUrl = url.EmailConfirmationLink(user.Id, code, scheme);

My ConfigureServices looks like this:

   services.AddIdentity<ApplicationUser, IdentityRole>(config =>
        {
            config.SignIn.RequireConfirmedEmail = true;
        })
            .AddEntityFrameworkStores<ApplicationDbContext>()
            .AddDefaultTokenProviders();

Thanks :)

like image 466
Scott L Avatar asked Oct 15 '18 17:10

Scott L


1 Answers

Adding the following code to ConfigureServices() method in Startup.cs class should help you.

services.Configure<DataProtectionTokenProviderOptions>(options =>
    options.TokenLifespan = TimeSpan.FromDays(2));

Default Token Lifespan is 24 hours (1 day). Please refer github and TokenOptions

like image 117
Charmis Varghese Avatar answered Nov 20 '22 21:11

Charmis Varghese