add checks for ticket lenght and format

This commit is contained in:
fram3d 2023-10-03 21:31:56 +02:00
parent 62833a2bd6
commit a3b7ff3f9f
Signed by: fram3d
GPG Key ID: 938920E709EEA32A

View File

@ -21,7 +21,11 @@ def submit():
elif request.method == 'POST': elif request.method == 'POST':
timenow = int(time.time()) timenow = int(time.time())
ticket_input = request.form['ticket'] ticket_input = request.form['ticket']
ticket = Ticket(ticket = ticket_input, timestamp = timenow)
if ticket_input.isdigit() and len(ticket_input) == 10:
ticket = Ticket(ticket = int(ticket_input), timestamp = timenow)
else:
return 'Ticket format is wrong. Only 10 digits allowed.'
try: try:
db.session.add(ticket) db.session.add(ticket)