Skip to content
Snippets Groups Projects
Unverified Commit 8a58af3b authored by me5na7qbjqbrp's avatar me5na7qbjqbrp
Browse files

Reformat apps/registration/tokens.py

parent 0c236251
No related branches found
No related tags found
2 merge requests!172WEI, diverses améliorations,!163More linting
Pipeline #8926 passed with warnings with stages
in 9 minutes and 28 seconds
...@@ -9,6 +9,7 @@ class AccountActivationTokenGenerator(PasswordResetTokenGenerator): ...@@ -9,6 +9,7 @@ class AccountActivationTokenGenerator(PasswordResetTokenGenerator):
""" """
Create a unique token generator to confirm email addresses. Create a unique token generator to confirm email addresses.
""" """
def _make_hash_value(self, user, timestamp): def _make_hash_value(self, user, timestamp):
""" """
Hash the user's primary key and some user state that's sure to change Hash the user's primary key and some user state that's sure to change
...@@ -23,9 +24,18 @@ class AccountActivationTokenGenerator(PasswordResetTokenGenerator): ...@@ -23,9 +24,18 @@ class AccountActivationTokenGenerator(PasswordResetTokenGenerator):
""" """
# Truncate microseconds so that tokens are consistent even if the # Truncate microseconds so that tokens are consistent even if the
# database doesn't support microseconds. # database doesn't support microseconds.
login_timestamp = '' if user.last_login is None else user.last_login.replace(microsecond=0, tzinfo=None) login_timestamp = (
return str(user.pk) + str(user.email) + str(user.profile.email_confirmed)\ ""
+ str(login_timestamp) + str(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() email_validation_token = AccountActivationTokenGenerator()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment