Commit 2bd0a85c authored by Ad Schellevis's avatar Ad Schellevis Committed by Franco Fichtner

(captiveportal) limit the max vouchers per call, closes https://github.com/opnsense/core/issues/722

(cherry picked from commit 0c8f5737)
parent ee259440
...@@ -113,6 +113,7 @@ class VoucherController extends ApiControllerBase ...@@ -113,6 +113,7 @@ class VoucherController extends ApiControllerBase
*/ */
public function generateVouchersAction($provider) public function generateVouchersAction($provider)
{ {
$response = array("status" => "error");
if ($this->request->isPost()) { if ($this->request->isPost()) {
$authFactory = new AuthenticationFactory(); $authFactory = new AuthenticationFactory();
$auth = $authFactory->get($provider); $auth = $authFactory->get($provider);
...@@ -120,11 +121,12 @@ class VoucherController extends ApiControllerBase ...@@ -120,11 +121,12 @@ class VoucherController extends ApiControllerBase
$count = $this->request->getPost('count', 'int', 0); $count = $this->request->getPost('count', 'int', 0);
$validity = $this->request->getPost('validity', 'int', 0); $validity = $this->request->getPost('validity', 'int', 0);
$vouchergroup = $this->request->getPost('vouchergroup', 'striptags', '---'); $vouchergroup = $this->request->getPost('vouchergroup', 'striptags', '---');
if ($count > 0 && $validity > 0) { if ($count > 0 && $count <= 10000 && $validity > 0) {
$response['status'] = 'created';
return $auth->generateVouchers($vouchergroup, $count, $validity); return $auth->generateVouchers($vouchergroup, $count, $validity);
} }
} }
} }
return array(); return $response;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment