Téléverser les fichiers vers "utils"

main
Anaz 2025-01-09 09:09:29 +01:00
parent c8c12372ef
commit d53e00b191
4 changed files with 18 additions and 0 deletions

BIN
utils/helpers.py Normal file

Binary file not shown.

BIN
utils/logging.py Normal file

Binary file not shown.

Binary file not shown.

18
utils/security.py Normal file
View File

@ -0,0 +1,18 @@
from passlib.context import CryptContext
from jose import jwt
from datetime import datetime, timedelta
from config.settings import settings
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
def get_password_hash(password: str) -> str:
return pwd_context.hash(password)
def verify_password(plain_password: str, hashed_password: str) -> bool:
return pwd_context.verify(plain_password, hashed_password)
def create_access_token(data: dict) -> str:
to_encode = data.copy()
expire = datetime.utcnow() + timedelta(minutes=settings.access_token_expire_minutes)
to_encode.update({"exp": expire})
return jwt.encode(to_encode, settings.secret_key, algorithm=settings.algorithm)