SQLAlchemy1.0->SQLAlchemy2.x Column->mapped-column

This commit is contained in:
2024-12-08 10:16:10 +09:00
parent 3aec075927
commit 91df7ed0fa
2 changed files with 107 additions and 107 deletions

View File

@@ -1,7 +1,7 @@
import jwt
from fastapi.security import OAuth2PasswordBearer
from passlib.context import CryptContext
from datetime import datetime, timedelta
from datetime import datetime, timedelta,timezone
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms
import os
import base64
@@ -27,9 +27,9 @@ def verify_password(plain_password: str, hashed_password: str) -> bool:
def create_access_token(*, data: dict, expires_delta: timedelta = None):
to_encode = data.copy()
if expires_delta:
expire = datetime.utcnow() + expires_delta
expire = datetime.now(timezone.utc) + expires_delta
else:
expire = datetime.utcnow() + timedelta(minutes=ACCESS_TOKEN_EXPIRE_MINUTES)
expire = datetime.now(timezone.utc) + timedelta(minutes=ACCESS_TOKEN_EXPIRE_MINUTES)
to_encode.update({"exp": expire})
encoded_jwt = jwt.encode(to_encode, SECRET_KEY, algorithm=ALGORITHM)
return encoded_jwt