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
.
Local users who forget their password can have a security token sent to their email account, enabling them to reset their password. The user will soon get an email with a link allowing them to reset their password. Selecting the link will take them to the Reset page.
After successful login a Change password link will be visible. Here by clicking the link a new page will appear where the user must enter the Current Password, New Password and Confirm Password and then click on the Update button to change his/her password respectively.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With