mirror of
https://github.com/open-webui/open-webui
synced 2024-11-24 21:13:59 +00:00
Merge pull request #4803 from CJDaniel96/dev
fix: DeprecationWarning for datetime.utcnow() by using datetime.now(UTC)
This commit is contained in:
commit
abe36a3e67
@ -6,7 +6,7 @@ from apps.webui.models.users import Users
|
|||||||
from typing import Union, Optional
|
from typing import Union, Optional
|
||||||
from constants import ERROR_MESSAGES
|
from constants import ERROR_MESSAGES
|
||||||
from passlib.context import CryptContext
|
from passlib.context import CryptContext
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta, UTC
|
||||||
import jwt
|
import jwt
|
||||||
import uuid
|
import uuid
|
||||||
import logging
|
import logging
|
||||||
@ -40,7 +40,7 @@ def create_token(data: dict, expires_delta: Union[timedelta, None] = None) -> st
|
|||||||
payload = data.copy()
|
payload = data.copy()
|
||||||
|
|
||||||
if expires_delta:
|
if expires_delta:
|
||||||
expire = datetime.utcnow() + expires_delta
|
expire = datetime.now(UTC) + expires_delta
|
||||||
payload.update({"exp": expire})
|
payload.update({"exp": expire})
|
||||||
|
|
||||||
encoded_jwt = jwt.encode(payload, SESSION_SECRET, algorithm=ALGORITHM)
|
encoded_jwt = jwt.encode(payload, SESSION_SECRET, algorithm=ALGORITHM)
|
||||||
|
Loading…
Reference in New Issue
Block a user