From 0b092b54672e88f3d30833adc98068ec79740379 Mon Sep 17 00:00:00 2001 From: Amritanshu Date: Tue, 17 Dec 2024 09:18:33 +0530 Subject: [PATCH] Fix: login failed as python-jose was removed. --- barker/barker/core/security.py | 6 +++--- barker/barker/main.py | 2 +- barker/barker/routers/reports/product_sale_report.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/barker/barker/core/security.py b/barker/barker/core/security.py index 6c22a5d..47f5a65 100644 --- a/barker/barker/core/security.py +++ b/barker/barker/core/security.py @@ -3,10 +3,10 @@ import uuid from datetime import UTC, datetime, timedelta from typing import Any +import jwt + from fastapi import Depends, HTTPException, Security, status from fastapi.security import OAuth2PasswordBearer, SecurityScopes -from jose import jwt -from jose.exceptions import ExpiredSignatureError from jwt import PyJWTError from pydantic import BaseModel, ValidationError from sqlalchemy import select @@ -82,7 +82,7 @@ async def get_current_user( raise credentials_exception token_scopes = payload.get("scopes", []) token_data = TokenData(scopes=token_scopes, username=username) - except (PyJWTError, ValidationError, ExpiredSignatureError): + except (PyJWTError, ValidationError): raise credentials_exception user = get_user( username=token_data.username, diff --git a/barker/barker/main.py b/barker/barker/main.py index 1619084..1d40aa3 100644 --- a/barker/barker/main.py +++ b/barker/barker/main.py @@ -117,5 +117,5 @@ app.include_router(split.router, prefix="/api", tags=["voucher"]) app.include_router(change.router, prefix="/api/voucher", tags=["voucher"]) -def init(): +def init() -> None: uvicorn.run(app, host=settings.HOST, port=settings.PORT) diff --git a/barker/barker/routers/reports/product_sale_report.py b/barker/barker/routers/reports/product_sale_report.py index 20cf7be..45e27e1 100644 --- a/barker/barker/routers/reports/product_sale_report.py +++ b/barker/barker/routers/reports/product_sale_report.py @@ -45,7 +45,7 @@ def product_sale_report_view( } -def product_sale_report(s: date, f: date, id_: uuid.UUID, db: Session): +def product_sale_report(s: date, f: date, id_: uuid.UUID | None, db: Session): start_date = datetime.combine(s, time()) + timedelta( minutes=settings.NEW_DAY_OFFSET_MINUTES - settings.TIMEZONE_OFFSET_MINUTES ) @@ -128,7 +128,7 @@ def print_report( "startDate": start_date.strftime("%d-%b-%Y"), "finishDate": finish_date.strftime("%d-%b-%Y"), "sectionId": str(section) if section is not None else None, - "amounts": product_sale_report(start_date, finish_date, db), + "amounts": product_sale_report(start_date, finish_date, section, db), } print_product_sale_report(report, device_id, db) return True