Skip to content

Commit

Permalink
Replaced django.utils.timezone.utc with datetime.timezone.utc
Browse files Browse the repository at this point in the history
isort formatted
  • Loading branch information
raydeal committed Sep 19, 2024
1 parent 740710c commit 6617725
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions misago/account/emailchange.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import hmac
import hashlib
import hmac
from base64 import urlsafe_b64decode, urlsafe_b64encode
from datetime import datetime, timedelta
from datetime import datetime, timedelta, timezone
from enum import StrEnum
from typing import TYPE_CHECKING

from django.conf import settings
from django.utils import timezone
from django.utils import timezone as dj_timezone
from django.utils.translation import pgettext

if TYPE_CHECKING:
Expand Down Expand Up @@ -60,7 +60,7 @@ def __str__(self):


def create_email_change_token(user: "User", new_email: str) -> str:
timestamp = timezone.now().strftime(TIMESTAMP_FORMAT)
timestamp = dj_timezone.now().strftime(TIMESTAMP_FORMAT)
payload = urlsafe_b64encode(f"{timestamp}:{new_email}".encode("utf-8"))
signature = get_email_change_signature(user, payload)

Expand All @@ -87,7 +87,7 @@ def read_email_change_token(user: "User", token: str) -> str:
)
expires = created + timedelta(hours=settings.MISAGO_EMAIL_CHANGE_TOKEN_EXPIRES)

if timezone.now() > expires:
if dj_timezone.now() > expires:
raise EmailChangeTokenError(EmailChangeTokenErrorCode.TOKEN_EXPIRED)

return email
Expand Down

0 comments on commit 6617725

Please sign in to comment.