有没有办法检查 ASP.NET Core Identity 中的 2FA 代码是否超时?

问题描述 投票:0回答:0

使用 Microsoft.AspNetCore.Identity.SignInManager 类进行 2FA 登录和身份验证时,输入 2FA 代码有几分钟的时间限制。

如果用户输入代码的时间太长,

GetTwoFactorAuthenticationUserAsync()
返回null,如下所示:

var user = await _signInManager.GetTwoFactorAuthenticationUserAsync();

if (user == null)
{
    throw new InvalidOperationException("Took too long to enter 2FA SMS code");
}

但我想知道是否有更好的方法来确定他们是否花了太长时间。似乎会有一种更优雅或“官方”的方式来检查这一点(似乎

GetTwoFactorAuthenticationUserAsync
可能会因其他原因返回 null。如果用户没有这样做,最好不要告诉用户他们花了太长时间)。

是否有内置属性或包含 2FA 代码(例如:短信中的号码)发送时间的内容?

或者除了检查 null 之外还有其他方法来检查 2FA 是否超时?

asp.net-core asp.net-core-identity two-factor-authentication
© www.soinside.com 2019 - 2024. All rights reserved.