From 8a58af3b31fb7cf01fa7ea582a457f77b0069e57 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Wed, 5 May 2021 19:48:19 +0200 Subject: [PATCH] Reformat apps/registration/tokens.py --- apps/registration/tokens.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/apps/registration/tokens.py b/apps/registration/tokens.py index 0e7b20a5..d49e613f 100644 --- a/apps/registration/tokens.py +++ b/apps/registration/tokens.py @@ -9,6 +9,7 @@ class AccountActivationTokenGenerator(PasswordResetTokenGenerator): """ Create a unique token generator to confirm email addresses. """ + def _make_hash_value(self, user, timestamp): """ Hash the user's primary key and some user state that's sure to change @@ -23,9 +24,18 @@ class AccountActivationTokenGenerator(PasswordResetTokenGenerator): """ # 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) + str(user.email) + str(user.profile.email_confirmed)\ - + str(login_timestamp) + str(timestamp) + login_timestamp = ( + "" + if user.last_login is None + else user.last_login.replace(microsecond=0, tzinfo=None) + ) + return ( + str(user.pk) + + str(user.email) + + str(user.profile.email_confirmed) + + str(login_timestamp) + + str(timestamp) + ) email_validation_token = AccountActivationTokenGenerator()