I would like to manually check the reset password token in ASP.NET Identity 2.0. I am trying to create my own version of UserManager.ResetPasswordAsync(string userId, string token, string newPassword) , which accepts IdentityUser instead of userId as follows:
UserManager.ResetPasswordAsync(IdentityUser user, string token, string newPassword)
Not sure if I am doing this correctly, but here I am trying to verify the code that was sent to the user by email at an earlier stage. I have not changed the code / token that sends an email to the user and generates a code. I assume this is the correct invocation method, but the purpose argument is incorrect. (I tried passing "ASP.NET Identity", but not cubes.)
if (await userManager.UserTokenProvider.ValidateAsync(purpose: "?", token: code, manager: userManager, user: user)) { return IdentityResult.Success; } else { return new IdentityResult("Invalid code."); }
If someone can fill me with details about how this works out of the box, or point me to the Microsoft source code for UserManager.ResetPasswordAsync(IdentityUser user, string token, string newPassword) , which would be most appreciated!
asp.net-mvc asp.net-identity asp.net-identity-2
Jeremy cook
source share