diff --git a/accounts/tokens.py b/accounts/tokens.py index 4b1f76baed1b9df1aaf24712c6869da3eb7851fa..9b362ab879849b5c64368ea79a7a37218a032c91 100644 --- a/accounts/tokens.py +++ b/accounts/tokens.py @@ -64,7 +64,10 @@ class EmailVerificationTokenGenerator: Running this data through salted_hmac() prevents cracking attempts, provided the secret isn't compromised. """ - return str(user.pk) + user.email + str(timestamp) + # Truncate microseconds so that tokens are consistent even if the + # database doesn't support microseconds. + login_timestamp = '' if user.last_login is None else user.last_login.replace(microsecond=0, tzinfo=None) + return str(user.pk) + user.email + str(timestamp) + str(login_timestamp) def _num_days(self, dt): return (dt - date(2001, 1, 1)).days