我想要手动验证ASP.NET身份2.0中的密码重置令牌。我试图创建我的版本UserManager.ResetPasswordAsync(string userId, string token, string 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.");
}
如果有人能向我解释一下它如何开箱即用,或者指向微软的源代码
UserManager.ResetPasswordAsync(IdentityUser user, string token, string newPassword)
,那就非常感激!
SetSecurityStampAsync
和SetPasswordHashAsync
而不是完整的UpdateAsync
...这不是ASP.NET Identity混乱中他们做的第一件愚蠢的事情... - Vincent