diff --git a/backend/app/auth.py b/backend/app/auth.py index 12fd25b..66b1214 100644 --- a/backend/app/auth.py +++ b/backend/app/auth.py @@ -2,7 +2,7 @@ from datetime import datetime, timedelta, timezone from typing import Optional from jose import JWTError, jwt -from passlib.context import CryptContext +import bcrypt from fastapi import Depends, HTTPException, status, Request from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy import select @@ -12,17 +12,16 @@ from app.models.admin_user import AdminUser settings = get_settings() -pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto") def verify_password(plain_password: str, hashed_password: str) -> bool: """Verify a plain password against a hash.""" - return pwd_context.verify(plain_password, hashed_password) + return bcrypt.checkpw(plain_password.encode(), hashed_password.encode()) def get_password_hash(password: str) -> str: """Hash a password using bcrypt.""" - return pwd_context.hash(password) + return bcrypt.hashpw(password.encode(), bcrypt.gensalt()).decode() def create_access_token(data: dict, expires_delta: timedelta | None = None) -> str: