【发布时间】:2014-08-26 01:39:51
【问题描述】:
背景:
我一直在使用微软团队here提供的Identity-Sample项目:
我已将 Identity-Sample 项目和预发布 nuget 包集成到现有项目中,该项目以前使用最新的稳定版 Identity。
问题:
在尝试 2FA 时,在 Account/SendCode 方法内,会调用 GetVerifiedUserIdAsync() ,它是 Microsoft.AspNet.Identity.Owin.SignInManager 类的一部分。 (见full code here)
GetVerifiedUserIdAsync() 正在返回 null(即它找不到经过验证的用户,即使我使用 1 个因素登录。)我认为它没有找到正确的 cookie .
当我运行Identity-Sample 应用程序时,我的浏览器显示_RequestVerificationToken 和TwoFactorCookie 并且一切正常。
当我运行自己的应用程序时,我的浏览器只显示_RequestVerificationToken cookie,我得到null。
问题:(如果 cookie 是问题)
当调用SignInManager.PasswordSignInAsync(...) 方法时(在Account/Login 内部),如何让我的应用正确设置cookie?
【问题讨论】:
-
我很困惑。
GetVerfiedUserIdAsync()应该如果你还没有验证你的用户(你说你只做了一个因素)返回 null,那么问题是什么? -
感谢您的浏览——我相信 GetVerifiedUserIdAsync() 应该在使用 1 个因素登录时提供 userId (User.Identity.GetUserId())。这似乎是微软团队提供的示例应用程序中所做的......
-
所以澄清一下,仍在寻找答案,如果有人有见解......
标签: .net asp.net-mvc-5 asp.net-identity two-factor-authentication