aboutsummaryrefslogtreecommitdiffstats
path: root/thallium-backend/src
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2024-08-19 01:37:26 +0100
committerGravatar Chris Lovering <[email protected]>2024-08-19 01:37:26 +0100
commitdec7cf29dfc61b1dc7b1767bf6eb5732e04d78b8 (patch)
tree5f29534f79e260cb9f056b594df2d7171fbdd39f /thallium-backend/src
parentUse the correct kwarg for a user when creating super user (diff)
Add an unauthenticated router as an example
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)