The second function return Activation link is invalid !
I tried to dig into the problem by examining the source code of the PasswordResetTokenGenerator class.
In the second function the code that i’m using employs a method of this class called check_token . This check if a given reset token is valid for a given user.
The init method of the PasswordGeneratorTokenGenerator class set self.algorithm = self.algorithm or “sha256”
The _make_token_with_timestamps generate a int_to_base_36 - HMAC string
but the HMAC string in generated with SHA1
I maybe completly wrong here but it is possible that the condition in my validate function didn’t become True due to to this difference of algorithms ?
Side note: Please do not post images of code. They can’t be indexed or searched in the forum, and they can’t be copied and quoted to highlight issues in specific areas of code.
Copy / paste your code into the body of your message surrounded by lines of three backtick - ` characters. This means that you’ll have a line of ```, then your code, then another line of ```. This forces the forum software to keep your code properly formatted.
I’m a bit confused by what you have here. You’ve got multiple references to objects or variables that aren’t defined in what you have posted. My initial reaction to what I’m seeing here is that I would expect this code to result in a 500 error on the page(s) referencing them.
Please post the complete functions.
In your first function, you reference a variable named account_activation_token. I don’t see where that has been defined, nor do I find a system variable, function, or class by that name.
In your second function, you’re using that same variable name - again, without a definition.
We’re going to need to see all the code that’s involved in this process to be able to properly try and diagnose this.
from django.contrib.auth.tokens import PasswordResetTokenGenerator
from django.utils import six
class TokenGenerator(PasswordResetTokenGenerator):
def _make_hash_value(self, user, timestamp):
return (six.text_type(user.pk)+six.text_type(timestamp)+six.text_type(user.is_active))
account_activation_token=TokenGenerator() ```