Replace deprecated method datetime.utcnow()

This commit is contained in:
grossmj 2024-05-18 23:33:26 +07:00
parent d56acc5844
commit 4b1068e02f
No known key found for this signature in database
GPG Key ID: 0A2D76AC45EA25CD

View File

@ -16,7 +16,7 @@
from jose import JWTError, jwt
from datetime import datetime, timedelta
from datetime import datetime, timedelta, timezone
import bcrypt
from typing import Optional
@ -48,7 +48,7 @@ class AuthService:
if not expires_in:
expires_in = Config.instance().settings.Controller.jwt_access_token_expire_minutes
expire = datetime.utcnow() + timedelta(minutes=expires_in)
expire = datetime.now(timezone.utc) + timedelta(minutes=expires_in)
to_encode = {"sub": username, "exp": expire}
if secret_key is None:
secret_key = Config.instance().settings.Controller.jwt_secret_key