Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions django_email_verification/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ class EmailVerificationTokenGenerator:
key_salt = "django-email-verification.token"
algorithm = None
secret = settings.SECRET_KEY
try:
accounts_locked = settings.EMAIL_ACCOUNTS_LOCKED
except AttributeError:
accounts_locked = True

def make_token(self, user, expiry=None):
"""
Expand Down Expand Up @@ -112,9 +116,8 @@ 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):
login_timestamp = '' if user.last_login is None else user.last_login.replace(microsecond=0, tzinfo=None)
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)

@staticmethod
Expand Down