Reputation: 3294
I have a web application in MVC5 with OWIN Identity and i want to know if there is a posibility to change from code a user password with out knowing the old password. Because the method ChangePassword
ask for userId
, oldPassword
and newPassword
.
Upvotes: 12
Views: 10518
Reputation: 4658
In this case you will be treating ChangePassword as Reset Password. You can achieve this by using reset password by generating token and using that token straightaway to validate it with new password.
var userId = User.Identity.GetUserId();
var token = await UserManager.GeneratePasswordResetTokenAsync(userId);
var result = await UserManager.ResetPasswordAsync(userId, token, newPassword);
Check this one for more details.
Hope this helps.
Upvotes: 36