Merge pull request #4803 from CJDaniel96/dev

fix: DeprecationWarning for datetime.utcnow() by using datetime.now(UTC)
This commit is contained in:
Timothy Jaeryang Baek 2024-08-22 13:57:57 +02:00 committed by GitHub
commit abe36a3e67
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6,7 +6,7 @@ from apps.webui.models.users import Users
from typing import Union, Optional
from constants import ERROR_MESSAGES
from passlib.context import CryptContext
from datetime import datetime, timedelta
from datetime import datetime, timedelta, UTC
import jwt
import uuid
import logging
@ -40,7 +40,7 @@ def create_token(data: dict, expires_delta: Union[timedelta, None] = None) -> st
payload = data.copy()
if expires_delta:
expire = datetime.utcnow() + expires_delta
expire = datetime.now(UTC) + expires_delta
payload.update({"exp": expire})
encoded_jwt = jwt.encode(payload, SESSION_SECRET, algorithm=ALGORITHM)