Tôi nghĩ bạn phải thay đổi thời gian hợp lệ trong UserTokenProvider
.
Hãy thử như sau trong UserManager<TApplicationUser>
thực hiện của bạn:
public static ApplicationUserManager Create(
IdentityFactoryOptions<ApplicationUserManager> options,
IOwinContext context)
{
/* ...create the user store... */
var manager = new ApplicationUserManager(userStore);
/* ...all the other config stuff... */
var dataProtectionProvider = options.DataProtectionProvider;
if (dataProtectionProvider != null)
{
var tokenProvider = new DataProtectorTokenProvider<ApplicationUser>(dataProtectionProvider.Create("ASP.NET Identity"));
// here's what you're looking for:
tokenProvider.TokenLifespan = TimeSpan.FromMinutes(10);
manager.UserTokenProvider = tokenProvider;
}
return manager;
}
Để làm việc này bạn cũng đã thay đổi thời gian chờ cookie hai yếu tố trong file StartUp như thế này: UseTwoFactorSignInCookie (DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes (10)); –