Sco*_*t L 3 asp.net asp.net-identity identityserver4 asp.net-core-2.1
我已经在.NET Core 2.1中设置了Identity Server 4项目,一切正常,但是当我使用用户管理器生成重置密码令牌时,该令牌在24小时后过期,我可以更改为48小时吗?
我发送重置令牌的代码如下所示:
var code = await _userManager.GeneratePasswordResetTokenAsync(user);
var callbackUrl = url.EmailConfirmationLink(user.Id, code, scheme);
Run Code Online (Sandbox Code Playgroud)
我的ConfigureServices看起来像这样:
services.AddIdentity<ApplicationUser, IdentityRole>(config =>
{
config.SignIn.RequireConfirmedEmail = true;
})
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
Run Code Online (Sandbox Code Playgroud)
谢谢 :)
将以下代码添加到Startup.cs类的ConfigureServices()方法中将对您有所帮助。
services.Configure<DataProtectionTokenProviderOptions>(options =>
options.TokenLifespan = TimeSpan.FromDays(2));
Run Code Online (Sandbox Code Playgroud)
默认令牌寿命为24小时(1天)。请参考github和TokenOptions
| 归档时间: |
|
| 查看次数: |
1993 次 |
| 最近记录: |