0
votes

I have some custom registration logic in my project and I want it to work this way:

  1. Someone requests access using special page (Implemented)
  2. New User is created. (Implemented)
  3. Server sends an email using Django's send_mail with a single-use link to a password setup page. (Yet to be implemented)

What's the simplest way to create a single-use link and/or password reset token this using Django's default password reset mechanism?

1

1 Answers

1
votes

You can use create the desired functionality by implementing very less code.

Follow the below steps:

  1. create a token when registering the user using django's PasswordResetTokenGenerator class
  2. Modify your registration view and set user's is_active status to false and send user an email with confirm email url containing the token.
  3. create view and url to handle user's action when he/she click on email link and set is_active status to true

You can follow below link for a great tutorial for implementing confirm email functionality in django : https://medium.com/@frfahim/django-registration-with-confirmation-email-bb5da011e4ef