Skip to content

Commit b86882f

Browse files
author
Lung
committed
added GET status guard and server-side price validation
1 parent 0fdf7a3 commit b86882f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Participant/Admin/AdminController.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,12 +397,19 @@ public function cancelPayment(
397397
}
398398

399399
public function showChangePaymentPrice(
400+
Request $request,
400401
Response $response,
401402
Event $event,
402403
int $paymentId,
403404
): Response {
404405
$payment = $this->paymentRepository->getById($paymentId, $event);
405406

407+
if ($payment->status !== PaymentStatus::Waiting) {
408+
$this->flashMessages->warning('flash.warning.paymentNotWaitingCannotChangePrice');
409+
410+
return $this->redirect($request, $response, 'admin-show-payments');
411+
}
412+
406413
return $this->view->render($response, 'admin/changePaymentPrice.twig', ['payment' => $payment]);
407414
}
408415

@@ -422,6 +429,12 @@ public function changePaymentPrice(
422429
return $this->redirect($request, $response, 'admin-show-payments');
423430
}
424431

432+
if ($newPrice < 0 || $newPrice > 99999) {
433+
$this->flashMessages->warning('flash.warning.paymentNotWaitingCannotChangePrice');
434+
435+
return $this->redirect($request, $response, 'admin-show-payments');
436+
}
437+
425438
$this->participantService->changePaymentPrice($payment, $newPrice, $reason);
426439
$this->flashMessages->success('flash.success.paymentPriceChanged');
427440
$this->logger->info('Payment ID ' . $paymentId . ' price changed to ' . $newPrice . ' with reason: ' . $reason);

0 commit comments

Comments
 (0)