From e1e7623d23a854932977b5791049426137a1210b Mon Sep 17 00:00:00 2001 From: Evan Borchert Date: Wed, 28 Jul 2021 08:55:31 -0400 Subject: [PATCH 1/3] DASH-1813 Added necessary settings --- django_email_verification/token.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/django_email_verification/token.py b/django_email_verification/token.py index 97553f4..74451f8 100644 --- a/django_email_verification/token.py +++ b/django_email_verification/token.py @@ -47,6 +47,7 @@ class EmailVerificationTokenGenerator: key_salt = "django-email-verification.token" algorithm = None secret = settings.SECRET_KEY + accounts_locked = getattr(settings, EMAIL_ACCOUNT_LOCKED, True) def make_token(self, user, expiry=None): """ @@ -114,7 +115,7 @@ def _make_token_with_timestamp(self, user, timestamp): @staticmethod def _make_hash_value(user, timestamp): - login_timestamp = '' if user.last_login is None else user.last_login.replace(microsecond=0, tzinfo=None) + login_timestamp = '' if user.last_login is None or not self.accounts_locked else user.last_login.replace(microsecond=0, tzinfo=None) return str(user.pk) + user.password + str(login_timestamp) + str(timestamp) @staticmethod From d7c566a030b46397249897eded364507bde81322 Mon Sep 17 00:00:00 2001 From: Evan Borchert Date: Wed, 28 Jul 2021 10:18:12 -0400 Subject: [PATCH 2/3] DASH-1813 Updated settings logic --- django_email_verification/token.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/django_email_verification/token.py b/django_email_verification/token.py index 74451f8..b4cb19d 100644 --- a/django_email_verification/token.py +++ b/django_email_verification/token.py @@ -47,7 +47,10 @@ class EmailVerificationTokenGenerator: key_salt = "django-email-verification.token" algorithm = None secret = settings.SECRET_KEY - accounts_locked = getattr(settings, EMAIL_ACCOUNT_LOCKED, True) + try: + accounts_locked = settings.EMAIL_ACCOUNTS_LOCKED + except AttributeError: + accounts_locked = True def make_token(self, user, expiry=None): """ From 622b39afafe81517a6371f5da18fc6722babdf96 Mon Sep 17 00:00:00 2001 From: Evan Borchert Date: Wed, 28 Jul 2021 10:39:40 -0400 Subject: [PATCH 3/3] DASH-1813 updated method for self --- django_email_verification/token.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/django_email_verification/token.py b/django_email_verification/token.py index b4cb19d..a27fc30 100644 --- a/django_email_verification/token.py +++ b/django_email_verification/token.py @@ -116,8 +116,7 @@ def _make_token_with_timestamp(self, user, timestamp): return f'{email_b64}-{ts_b36}-{hash_string}', \ datetime.fromtimestamp(timestamp + settings.EMAIL_TOKEN_LIFE) - @staticmethod - def _make_hash_value(user, timestamp): + def _make_hash_value(self, user, timestamp): login_timestamp = '' if user.last_login is None or not self.accounts_locked else user.last_login.replace(microsecond=0, tzinfo=None) return str(user.pk) + user.password + str(login_timestamp) + str(timestamp)