updated for deployment

This commit is contained in:
rarebuffalo
2026-04-20 11:05:59 +05:30
parent 8330060e86
commit 5f214c507d
4 changed files with 132 additions and 6 deletions

View File

@@ -1,19 +1,25 @@
from datetime import datetime, timedelta, timezone
import bcrypt
from jose import JWTError, jwt
from passlib.context import CryptContext
from app.config import settings
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
def hash_password(password: str) -> str:
return pwd_context.hash(password)
pwd_bytes = password.encode("utf-8")
salt = bcrypt.gensalt()
return bcrypt.hashpw(pwd_bytes, salt).decode("utf-8")
def verify_password(plain_password: str, hashed_password: str) -> bool:
return pwd_context.verify(plain_password, hashed_password)
try:
return bcrypt.checkpw(
plain_password.encode("utf-8"),
hashed_password.encode("utf-8")
)
except ValueError:
return False
def create_access_token(user_id: str) -> str: