backend for queues & minor front tweaks
This commit is contained in:
@ -68,10 +68,3 @@ async def read_users_me(
|
||||
current_user: Annotated[schemas.User, Depends(services.get_current_active_user)],
|
||||
):
|
||||
return current_user
|
||||
|
||||
|
||||
# @app.get("/users/me/items/")
|
||||
# async def read_own_items(
|
||||
# current_user: Annotated[User, Depends(get_current_active_user)],
|
||||
# ):
|
||||
# return [{"item_id": "Foo", "owner": current_user.username}]
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
from typing import Union
|
||||
from pydantic import BaseModel
|
||||
from uuid import UUID
|
||||
|
||||
|
||||
class User(BaseModel):
|
||||
@ -8,7 +9,7 @@ class User(BaseModel):
|
||||
|
||||
|
||||
class UserInDB(User):
|
||||
hashed_password: str
|
||||
id: UUID
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
@ -20,15 +20,15 @@ def verify_password(plain_password, hashed_password):
|
||||
return pwd_context.verify(plain_password, hashed_password)
|
||||
|
||||
|
||||
def get_password_hash(password):
|
||||
def get_password_hash(password) -> str:
|
||||
return pwd_context.hash(password)
|
||||
|
||||
|
||||
def get_user_by_id(db: Session, user_id: uuid.uuid4):
|
||||
def get_user_by_id(db: Session, user_id: uuid.uuid4) -> models.User:
|
||||
return db.query(models.User).filter(models.User.id == user_id).first()
|
||||
|
||||
|
||||
def get_user_by_username(db: Session, username: int):
|
||||
def get_user_by_username(db: Session, username: int) -> models.User:
|
||||
return db.query(models.User).filter(models.User.username == username).first()
|
||||
|
||||
|
||||
@ -62,15 +62,13 @@ def create_user(db: Session, user_data: schemas.UserRegister) -> schemas.UserInD
|
||||
)
|
||||
db.add(user)
|
||||
db.commit()
|
||||
return schemas.UserInDB(
|
||||
username=user.username, name=user.name, hashed_password=user.hashed_password
|
||||
)
|
||||
return schemas.UserInDB.model_validate(user)
|
||||
|
||||
|
||||
async def get_current_user(
|
||||
token: Annotated[str, Depends(oauth2_scheme)],
|
||||
db: Annotated[Session, Depends(get_db)],
|
||||
) -> schemas.User:
|
||||
) -> schemas.UserInDB:
|
||||
credentials_exception = HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail="Could not validate credentials",
|
||||
|
||||
Reference in New Issue
Block a user