feat:修复BUG
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user