我想在ASP.NET Identity 2.0中手动验证密码重置令牌.我正在尝试创建我自己的UserManager.ResetPasswordAsync版本(字符串userId,字符串标记,字符串newPassword)和IdentityUser而不是userId,如下所示:
UserManager.ResetPasswordAsync(IdentityUser user,string token,string newPassword)
不确定我是否正确这样做,但在这里我试图验证在之前的步骤中通过电子邮件发送给用户的代码.我没有修改将电子邮件发送给用户并生成代码的代码/令牌.我假设这是正确的调用方法,但目的参数不正确. (我尝试传递“ASP.NET身份”,但没有骰子.)
if (await userManager.UserTokenProvider.ValidateAsync(purpose: "?",token: code,manager: userManager,user: user)) { return IdentityResult.Success; } else { return new IdentityResult("Invalid code."); }
如果有人可以填写我开箱即用的详细信息,或者指向Microsoft的UserManager.ResetPasswordAsync(IdentityUser用户,字符串newPassword)的源代码,我将不胜感激!
解决方法
根据位于以下位置的Codeplex存储库,Microsoft.AspNet.Identity的代码似乎尚未开源.
https://aspnetidentity.codeplex.com/SourceControl/latest#Readme.markdown
At present,the ASP.NET Identity framework code is not public and
therefore will not be published on this site. However,we are planning
to change that,and as soon as we are able,the code will be published
in this repository.
但是我确实发现了这可能是基于调试符号的UserManager的源:
我也发现这些帖子可能会有所帮助:
Implementing custom password policy using ASP.NET Identity