feat:修复BUG

This commit is contained in:
2026-01-09 17:28:20 +08:00
parent 67025a4865
commit 26e021ee44
4 changed files with 63 additions and 23 deletions

View File

@@ -1,18 +1,20 @@
from datetime import datetime, timedelta
import bcrypt
from jose import jwt, JWTError
from passlib.context import CryptContext
from ..core import get_settings
settings = get_settings()
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
def hash_password(password: str) -> str:
return pwd_context.hash(password)
return bcrypt.hashpw(password.encode("utf-8"), bcrypt.gensalt()).decode("utf-8")
def verify_password(plain: str, hashed: str) -> bool:
return pwd_context.verify(plain, hashed)
try:
return bcrypt.checkpw(plain.encode("utf-8"), hashed.encode("utf-8"))
except Exception:
return False
def create_token(data: dict) -> str: