Skip to content

Commit bdd167c

Browse files
authored
validate attendee id from request (#9064)
* feature-9029: vaildate attendee input
1 parent 2eaaf0e commit bdd167c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

app/api/custom/badge_forms.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from flask_jwt_extended import jwt_required
44

55
from app.api.helpers.badge_forms import create_preivew_badge_pdf
6-
from app.api.helpers.errors import ForbiddenError, NotFoundError
6+
from app.api.helpers.errors import ForbiddenError, NotFoundError, UnprocessableEntityError
77
from app.api.helpers.export_helpers import (
88
comma_separated_params_to_list,
99
create_export_badge_job,
@@ -48,8 +48,14 @@ def print_badge_pdf():
4848
)
4949
attendee_id = request.args.get('attendee_id')
5050
list_field_show = comma_separated_params_to_list(request.args.get('list_field_show'))
51-
52-
ticket_holder = TicketHolder.query.filter_by(id=attendee_id).first()
51+
if isinstance(attendee_id, int) or (
52+
isinstance(attendee_id, str) and attendee_id.isdigit()
53+
):
54+
ticket_holder = TicketHolder.query.filter_by(id=attendee_id).first()
55+
else:
56+
raise UnprocessableEntityError(
57+
{'pointer': 'ticket_holder'}, "Invalid Attendee Id"
58+
)
5359
if ticket_holder is None:
5460
raise NotFoundError(
5561
{'source': ''}, 'This ticket holder is not associated with any ticket'

0 commit comments

Comments
 (0)