Asp.net Can';t配置UserCookie以返回用于双因素身份验证的正确SignInStatus
根据MSDN 本地登录和社交登录都会检查2FA是否已启用。如果启用了2FA,SignInManager登录方法将返回SignInStatus.RequiresVerification,用户将被重定向到SendCode操作方法,在该方法中,用户必须输入代码才能按顺序完成登录如果在用户本地cookie上设置了用户已记忆RME,则SignInManager将返回SignInStatus.Success,并且他们不必通过2FA。 我确实希望用户能够使用应用程序的“记住我”功能,但我不知道如何让cookie放弃此设置,以便SignInStatus返回RequiresVerifaction。事实上,我甚至不能100%确定是饼干引起的。我所知道的是,我已经启用了TFA,在AspUsers表中,我可以看到TwoFactorEnabled设置为true,但状态始终返回为Success 这是控制器,我没有得到我想要的Asp.net Can';t配置UserCookie以返回用于双因素身份验证的正确SignInStatus,asp.net,asp.net-mvc,cookies,asp.net-identity,two-factor-authentication,Asp.net,Asp.net Mvc,Cookies,Asp.net Identity,Two Factor Authentication,根据MSDN 本地登录和社交登录都会检查2FA是否已启用。如果启用了2FA,SignInManager登录方法将返回SignInStatus.RequiresVerification,用户将被重定向到SendCode操作方法,在该方法中,用户必须输入代码才能按顺序完成登录如果在用户本地cookie上设置了用户已记忆RME,则SignInManager将返回SignInStatus.Success,并且他们不必通过2FA。 我确实希望用户能够使用应用程序的“记住我”功能,但我不知道如何让cooki
[AllowAnonymous]
public async Task<ActionResult> ExternalLoginCallback(string returnUrl)
{
var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
if (loginInfo == null)
{
return RedirectToAction("Login");
}
// Sign in the user with this external login provider if the user already has a login
var result = await SignInManager.ExternalSignInAsync(loginInfo, isPersistent: false);
var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
switch (result)
{
case SignInStatus.Success:
return RedirectToLocal(returnUrl);
case SignInStatus.LockedOut:
return View("Lockout");
case SignInStatus.RequiresVerification:
return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = false });
case SignInStatus.Failure:
default:
// If the user does not have an account, then prompt the user to create an account
ViewBag.ReturnUrl = returnUrl;
ViewBag.LoginProvider = loginInfo.Login.LoginProvider;
return View("ExternalLoginConfirmation", new ExternalLoginConfirmationViewModel { Email = loginInfo.Email });
}
}
[AllowAnonymous]
public async Task var result应返回SignInStatus.RequiresVerification,但从google的OAuth登录返回时,或仅从常规登录返回时,将返回Success。用户在AspUsers表中将其TwoFactorEnabled设置为true,这是根据文档检查的结果。此问题的解决方案实际上非常简单。你只需要知道你在做什么。ASP身份很复杂,有很多活动部件。如果有人在这篇文章中遇到与ASP.NET身份相关的问题,我建议从Microsoft视频系列开始,介绍如何自定义ASP身份。那里有很多信息。对于使用QR码实现Google Authenticator风格的TFA最有帮助的教程是您在调用登录方法的地方有代码吗?