aboutsummaryrefslogtreecommitdiffstats
path: root/thallium-backend/src
diff options
context:
space:
mode:
Diffstat (limited to 'thallium-backend/src')
-rw-r--r--thallium-backend/src/routes/vouchers.py15
1 files changed, 9 insertions, 6 deletions
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.dto import Voucher
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__)
+@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)