加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – 在ASP.NET Identity中手动验证密码重置令牌

发布时间:2020-12-15 22:18:04 所属栏目:asp.Net 来源:网络整理
导读:我想在ASP.NET Identity 2.0中手动验证密码重置令牌.我正在尝试创建我自己的UserManager.ResetPasswordAsync版本(字符串userId,字符串标记,字符串newPassword)和IdentityUser而不是userId,如下所示: UserManager.ResetPasswordAsync(IdentityUser user,stri
我想在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的源:

UserManager Source Code

我也发现这些帖子可能会有所帮助:

Implementing custom password policy using ASP.NET Identity

UserManager Class Documentation

IUserTokenProvider Interface Documentation

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读