How should I implement "Forgot your password" in ASP.NET MVC?

Sitherax picture Sitherax · Aug 22, 2009 · Viewed 25.8k times · Source

I'm using the standard SqlMembershipProvider that comes with the ASP.NET MVC demo.

I'm interested in implementing a "Forgot your password" link on my site.

What is the correct way for this feature to be implemented? Should I overwrite the password with a temporary one and email it to their registered email?

Answer

Rasik Jain picture Rasik Jain · Aug 23, 2009

Based on the nature of the application, the Best practice for the forgot password should be in following order

  1. Allow the user to verify the Secret/Question for a maximum of 3 to 5 attempts
  2. On successful validation, Send an e-mail with random generated password with a validity of 24hrs.
  3. The e-mail must contain only the password but not both username/password.
  4. When user logs in with temporary password, then user must be forced to create a new password before going to home page.