Skip to content

Instantly share code, notes, and snippets.

@LouisdeBruijn
Created May 9, 2020 14:52
Show Gist options
  • Select an option

  • Save LouisdeBruijn/a6c020dfd4bdeabcceb59237667d3d70 to your computer and use it in GitHub Desktop.

Select an option

Save LouisdeBruijn/a6c020dfd4bdeabcceb59237667d3d70 to your computer and use it in GitHub Desktop.
from django.contrib.auth.tokens import PasswordResetTokenGenerator
from django.utils import six
class AccountActivationTokenGenerator(PasswordResetTokenGenerator):
def _make_hash_value(self, user, timestamp):
return (
six.text_type(user.pk) + six.text_type(timestamp) +
six.text_type(user.profile.email_confirmed)
)
class PasswordResetToken(PasswordResetTokenGenerator):
def _make_hash_value(self, user, timestamp):
return (
six.text_type(user.pk) + six.text_type(timestamp) +
six.text_type(user.profile.reset_password)
)
account_activation_token = AccountActivationTokenGenerator()
password_reset_token = PasswordResetToken()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment