2

Using ASP.NET Identity I need the ability to do a ChangePassword at an administrative level without knowing the existing User's password. Unfortunately UserManager.ChangePasswordAsync requires the existing password to change.

My workaround is to use the ResetPassword functionality instead. But rather than using e-mail simply do everything behind the scenes as follows:

var code = await _userManager.GeneratePasswordResetTokenAsync(user);
await _userManager.ResetPasswordAsync(user, code, newPassword);

However the password reset/update is not working and I am not getting any error. I am assuming it could be from a few things.

  1. Is there a field in the AspNetUsers table that stores this code when GeneratePasswordReset is called? If so can someone please tell me what this field is because I am using a CustomUserStore and my User table doesn't have whatever field it may be.
  2. Since I am using a Custom User store do I additionally have to implement another interface such as: IUserSecurityStampStore?

UPDATE:

I found out that Identity uses the SecurityStamp field to generate the token and check the token that is created when generating and resetting the password. I added the SecurityStamp field to my custom User table and see that it is set after creating a new user. Then I go to change the user's password with the above code and is is still not changing with no error. I must be missing something else.

Blake Rivell
  • 13,105
  • 31
  • 115
  • 231
  • Hi. Did you ever figure this out? – Henrik Clausen Oct 09 '17 at 11:32
  • @HenrikClausen Yes, I didn't implement all of the functions in my custom user store. It was either that or I was missing a property or two in my custom classes. Sorry I can't remember the exact thing I did. I am not sure if you are using custom stores also. If you are please follow exact instructions from the ASP.NET Core docs. If this isn't the case for you and you are just using defaults I am sorry but I am not sure why it isn't working for you. – Blake Rivell Oct 09 '17 at 14:05
  • @HenrikClausen https://stackoverflow.com/questions/28665431/why-is-resetpasswordasync-not-working – Blake Rivell Oct 09 '17 at 14:07

0 Answers0