Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Email Token Expiring After 15 mins - Asp Identity 2.0 API

I'm facing a strange issue in Asp Dot Net Identity API 2.0 API.

When an user signs up, I send a confirmation email to the user. And if the user confirms his / her account within 15 mins of signing up, the "ConfirmEmailAsync" method seems to be working.

But after 15 mins, if I try to confirm the email address, I'm getting a "Invalid Token" error.

Is there a way to set the token expiry time?

A really frustrating issue and it's becoming very hard to troubleshoot.

Can anyone help please?

like image 888
Vishwas Shashidhar Avatar asked Nov 26 '14 15:11

Vishwas Shashidhar


1 Answers

Change the code in the Create method(App_Start\IdentityConfig.cs file).

if (dataProtectionProvider != null)
 {
    manager.UserTokenProvider =
       new DataProtectorTokenProvider<ApplicationUser>
          (dataProtectionProvider.Create("ASP.NET Identity"))
          {                    
             TokenLifespan = TimeSpan.FromHours(3)
          };
 }

source: http://www.asp.net/identity/overview/features-api/account-confirmation-and-password-recovery-with-aspnet-identity

like image 169
rogerdeuce Avatar answered Oct 22 '22 19:10

rogerdeuce