setting expiration time to django password reset token

Sar009 picture Sar009 · Jan 16, 2014 · Viewed 11.8k times · Source

I am using the inbuilt password reset functionality of Django which emails the user the password reset link. Is there an option in Django to set an expiration time to the link suppose 6 hours after which the link become invalid and user will have to request again for password recovery.

Answer

Ed Patrick Tan picture Ed Patrick Tan · Mar 20, 2014

If you're using Django's built-in password reset functionality, you can use the setting PASSWORD_RESET_TIMEOUT_DAYS.

Example: if a user uses a password reset link that was generated 2 days ago and you have PASSWORD_RESET_TIMEOUT_DAYS=1 in your project's settings, the link will be invalid and the user cannot continue.

More info here: https://docs.djangoproject.com/en/2.2/ref/settings/#password-reset-timeout-days