From 01885e15463bf9bb96faad56d2aa70432382df1c Mon Sep 17 00:00:00 2001 From: Dorian Lesbre <dorian.lesbre@gmail.com> Date: Sun, 21 Mar 2021 14:52:17 +0100 Subject: [PATCH] Fixes #5 --- accounts/tokens.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/accounts/tokens.py b/accounts/tokens.py index 4b1f76b..9b362ab 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 -- GitLab