diff --git a/thallium-backend/src/routes/vouchers.py b/thallium-backend/src/routes/vouchers.py index 97b9fef..26770e9 100644 --- a/thallium-backend/src/routes/vouchers.py +++ b/thallium-backend/src/routes/vouchers.py @@ -8,17 +8,20 @@ from src.orm import Voucher as DBVoucher from src.settings import DBSession -router = APIRouter( - prefix="/vouchers", - tags=["Voucher users"], - dependencies=[Depends(TokenAuth(allow_vouchers=True))], -) +router = APIRouter(prefix="/vouchers", tags=["Voucher users"]) +authenticated_router = APIRouter(dependencies=[Depends(TokenAuth(allow_vouchers=True))]) +unauthenticated_router = APIRouter() + log = logging.getLogger(__name__) -@router.get("/me") +@authenticated_router.get("/me") async def get_vouchers(request: Request, db: DBSession) -> Voucher | None: """Get the voucher for the currently authenticated voucher id.""" stmt = select(DBVoucher).where(DBVoucher.id == request.state.voucher_id) res = await db.execute(stmt) return res.scalars().one_or_none() + + +router.include_router(authenticated_router) +router.include_router(unauthenticated_router)