mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-12-02 21:30:16 +09:00
Harden Admin API input handling (#3247)
This commit is contained in:
1 parent
cf6d7f33e4
commit
5bb75fa908
5 files changed
+24
-15
No files matched your search
@@ -31,15 +31,18 @@ class Admin extends \Api_Abstract
|
||||
$pager = $this->di['pager']->getPaginatedResultSet($sql, $params, $per_page);
|
||||
|
||||
foreach ($pager['list'] as $key => $item) {
|
||||
if (!is_array($item)) {
|
||||
continue;
|
||||
}
|
||||
$pager['list'][$key] = [
|
||||
'id' => $item['id'],
|
||||
'client_id' => $item['client_id'],
|
||||
'sender' => $item['sender'],
|
||||
'recipients' => $item['recipients'],
|
||||
'subject' => $item['subject'],
|
||||
'content_html' => $item['content_html'],
|
||||
'content_text' => $item['content_text'],
|
||||
'created_at' => $item['created_at'],
|
||||
'id' => $item['id'] ?? null,
|
||||
'client_id' => $item['client_id'] ?? null,
|
||||
'sender' => $item['sender'] ?? '',
|
||||
'recipients' => $item['recipients'] ?? '',
|
||||
'subject' => $item['subject'] ?? '',
|
||||
'content_html' => $item['content_html'] ?? '',
|
||||
'content_text' => $item['content_text'] ?? '',
|
||||
'created_at' => $item['created_at'] ?? '',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -225,8 +225,9 @@ class Admin extends \Api_Abstract
|
||||
public function config_get($data)
|
||||
{
|
||||
$service = $this->getService();
|
||||
$ext = $data['ext'] ?? null;
|
||||
|
||||
return $service->getConfig($data['ext']);
|
||||
return $service->getConfig($ext);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -660,9 +660,12 @@ class Admin extends \Api_Abstract
|
||||
[$sql, $params] = $subscriptionService->getSearchQuery($data);
|
||||
$per_page = $data['per_page'] ?? $this->di['pager']->getDefaultPerPage();
|
||||
$pager = $this->di['pager']->getPaginatedResultSet($sql, $params, $per_page);
|
||||
foreach ($pager['list'] as $key => $item) {
|
||||
$subscription = $this->di['db']->getExistingModelById('Subscription', $item['id'], 'Subscription not found');
|
||||
$pager['list'][$key] = $subscriptionService->toApiArray($subscription);
|
||||
|
||||
if (isset($pager['list']) && is_array($pager['list'])) {
|
||||
foreach ($pager['list'] as $key => $item) {
|
||||
$subscription = $this->di['db']->getExistingModelById('Subscription', $item['id'], 'Subscription not found');
|
||||
$pager['list'][$key] = $subscriptionService->toApiArray($subscription);
|
||||
}
|
||||
}
|
||||
|
||||
return $pager;
|
||||
|
||||
@@ -437,7 +437,8 @@ class Admin extends \Api_Abstract
|
||||
#[RequiredParams(['id' => 'Promo ID was not passed'])]
|
||||
public function promo_get($data)
|
||||
{
|
||||
$model = $this->di['db']->getExistingModelById('Promo', $data['id'], 'Promo not found');
|
||||
$id = $data['id'] ?? null;
|
||||
$model = $this->di['db']->getExistingModelById('Promo', $id, 'Promo not found');
|
||||
|
||||
return $this->getService()->toPromoApiArray($model, true, $this->getIdentity());
|
||||
}
|
||||
|
||||
@@ -103,9 +103,10 @@ class Admin extends \Api_Abstract
|
||||
])]
|
||||
public function change_password($data)
|
||||
{
|
||||
$this->di['validator']->isPasswordStrong($data['new_password']);
|
||||
$newPassword = $data['new_password'] ?? null;
|
||||
$this->di['validator']->isPasswordStrong($newPassword);
|
||||
|
||||
if ($data['new_password'] != $data['confirm_password']) {
|
||||
if ($newPassword != $data['confirm_password']) {
|
||||
throw new \FOSSBilling\InformationException('Passwords do not match');
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user