How to configure confirmation email token lifespan in asp.net core mvc

Gzim Helshani picture Gzim Helshani · May 17, 2017 · Viewed 8.2k times · Source

I'm trying to extend the lifespan of both confirmation emails and password reset emails but I can't manage to do so. Currently I'm using Asp.net core 1.0.1 if that's helpful.

Some tips or even better, the code, would be much appreciated.

Thank you

Answer

Viacheslav Yankov picture Viacheslav Yankov · Sep 8, 2017

Maybe it will help someone=)

Just do this:

    public void ConfigureServices(IServiceCollection services)
    {
        // ...
        services.Configure<DataProtectionTokenProviderOptions>(options =>
        {
            options.TokenLifespan = TimeSpan.FromDays(2); // Sets the expiry to two days
        });
    }

This works for me.