Asp.net-mvc – change password in MVC 4

asp.net-mvcauthenticationsimplemembership

I am building ASP.NET MVC 4 application. I use Simple Membership provider to manage authentication and authorization within the system. What are the ways of changing the password in this approach. I found a ChangePassword method which takes three parameters, including original password, to operate.

Is there any other way to override/change the password for the user without actually knowing original password?

Best Answer

ChangePassword is used when a user wants to change their password - and the current password is their evidence to allow this to happen (think Change Password Screen).

I think the most direct way to do this is to call WebSecurity.GeneratePasswordResetToken() and pass the result into WebSecurity.ResetPassword, along with the new password.

  var token = WebSecurity.GeneratePasswordResetToken("UserName");
  var result = WebSecurity.ResetPassword(token, "NewPassword");
Related Topic