diff --git a/backend/main.py b/backend/main.py index d9a8d300fe8f95a6b9ac8205675f1120b9715dea..6913f90d84b87fec326325674139ac227460ef54 100644 --- a/backend/main.py +++ b/backend/main.py @@ -74,7 +74,7 @@ def check_token(token: str, item_uuid: str): @app.post("/token") def verify_supporter(form_data: OAuth2PasswordRequestForm = Depends()): if form_data.password != settings.shared_secret: - raise HTTPException(status_code=400, detail="Incorrect username or password") + raise HTTPException(status_code=401, detail="Incorrect username or password") return { "access_token": oauth2_tokener.dumps("all"), "token_type": "bearer", @@ -204,90 +204,3 @@ def add_item_with_image( check_token(token, None) print(image.file) return False # utils.add_item_with_image(db, image) - - -# @app.post("/item/update/{item_uuid}", response_model=schemas.Delivery) -# def update_item( -# item_uuid: str, -# data: schemas.ItemUpdate, -# token: str = Depends(oauth2_scheme), -# db: Session = Depends(get_db), -# ): -# check_token(token, item_uuid) -# item = utils.get_item_by_uuid(db, UUID(item_uuid)) -# if not item: -# raise HTTPException(status_code=404, detail="Item not found") -# return utils.update_item(db, item, data) - - -# @app.get("/item/{item_uuid}", response_model=schemas.Delivery) -# def get_item( -# item_uuid: str, token: str = Depends(oauth2_scheme), db: Session = Depends(get_db) -# ): -# item = utils.get_item_by_uuid(db, UUID(item_uuid)) -# if not item: -# raise HTTPException(status_code=404, detail="Item not found") -# return item - - -# @app.get("/items", response_model=list[schemas.Delivery]) -# def get_items(token: str = Depends(oauth2_scheme), db: Session = Depends(get_db)): -# print(token) -# check_token(token, None) -# return utils.get_stored_items(db) - - -# @app.get("/tag/{tag}", response_model=schemas.Delivery) -# def get_item_by_tag( -# tag: str, token: str = Depends(oauth2_scheme), db: Session = Depends(get_db) -# ): -# check_token(token, None) -# item = utils.get_item_by_tag(db, tag) -# if not item: -# raise HTTPException(status_code=404, detail="Item not found") -# return item - - -# @app.get("/storage/{storage_name}", response_model=list[schemas.Delivery]) -# def get_storage( -# storage_name: str, -# token: str = Depends(oauth2_scheme), -# db: Session = Depends(get_db), -# ): -# check_token(token, None) -# return utils.get_items_for_storage(db, storage_name) - - -# @app.get("/storages", response_model=list[schemas.Storage]) -# def list_storages(token: str = Depends(oauth2_scheme), db: Session = Depends(get_db)): -# check_token(token, None) -# return utils.get_storages(db) - - -# @app.post("/checkin", response_model=schemas.Delivery) -# def checkin_item_by_uuid( -# checkin: schemas.ItemCheckin, -# token: str = Depends(oauth2_scheme), -# db: Session = Depends(get_db), -# ): -# check_token(token, None) -# item = utils.get_item_by_uuid(db, UUID(checkin.item_uuid)) -# if item is None: -# raise HTTPException(status_code=404, detail="Item not found") -# storage = utils.get_storage(db, checkin.storage_name) -# if storage is None: -# raise HTTPException(status_code=404, detail="Storage not found") -# return utils.receive_item(db, item, storage) - - -# @app.get("/checkout/{item_uuid}", response_model=schemas.Delivery) -# def checkout_item( -# item_uuid: str, -# token: str = Depends(oauth2_scheme), -# db: Session = Depends(get_db), -# ): -# check_token(token, None) -# item = utils.get_item_by_uuid(db, UUID(item_uuid)) -# if item is None: -# raise HTTPException(status_code=404, detail="Item not found") -# return utils.deliver_item(db, item)