0

I am making an application using django I am wondering what is the best solution for automatically deleting password reset instances from my PasswordReset model if a user hasn't reset their password within a day.

ResetPassword Model

class ResetPassword(models.Model):
    user = models.ForeignKey('auth.User')
    password_reset_token = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    password_reset_submission_date = models.DateField(auto_now_add=True,null=True,blank=True)

    def __str__(self):
        return self.user.username
thomaSmith
  • 263
  • 1
  • 9
  • 17
  • Insert the timestamp along with other password reset related data to the table. Run a scheduler inside your database once every 24 hours and delete records with timestamp older than 24 hours. Would that work? –  Apr 02 '17 at 10:31
  • is there any example code for doing this – thomaSmith Apr 02 '17 at 10:45
  • Here is an example of a scheduler for MySQL database http://stackoverflow.com/questions/3070277/mysql-event-scheduler-on-a-specific-time-everyday –  Apr 02 '17 at 10:48
  • There is no need to implement any of this; Django has password reset functionality built in. – Daniel Roseman Apr 02 '17 at 11:52

0 Answers0