|
|
@ -5,7 +5,7 @@ import jwt |
|
|
|
from fastapi import Depends, FastAPI, HTTPException, status |
|
|
|
from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm |
|
|
|
from jwt.exceptions import InvalidTokenError |
|
|
|
from passlib.context import CryptContext |
|
|
|
from pwdlib import PasswordHash |
|
|
|
from pydantic import BaseModel |
|
|
|
from typing_extensions import Annotated |
|
|
|
|
|
|
@ -47,7 +47,7 @@ class UserInDB(User): |
|
|
|
hashed_password: str |
|
|
|
|
|
|
|
|
|
|
|
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto") |
|
|
|
password_hash = PasswordHash.recommended() |
|
|
|
|
|
|
|
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token") |
|
|
|
|
|
|
@ -55,11 +55,11 @@ app = FastAPI() |
|
|
|
|
|
|
|
|
|
|
|
def verify_password(plain_password, hashed_password): |
|
|
|
return pwd_context.verify(plain_password, hashed_password) |
|
|
|
return password_hash.verify(plain_password, hashed_password) |
|
|
|
|
|
|
|
|
|
|
|
def get_password_hash(password): |
|
|
|
return pwd_context.hash(password) |
|
|
|
return password_hash.hash(password) |
|
|
|
|
|
|
|
|
|
|
|
def get_user(db, username: str): |
|
|
|