From 510e7815391fcc872e7c96ce59004e8b7bb2482f Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 8 Apr 2023 04:36:26 +0200 Subject: [PATCH] fix billing process --- .github/user_bug_report.md | 14 ++++++++++---- Controller/ApiController.php | 12 ++++++------ tests/ControllerTestTemp.php | 2 +- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.github/user_bug_report.md b/.github/user_bug_report.md index 9e5f2a5..4b92a8e 100755 --- a/.github/user_bug_report.md +++ b/.github/user_bug_report.md @@ -8,9 +8,11 @@ assignees: '' --- # Bug Description + A clear and concise description of what the bug is. # How to Reproduce + Steps to reproduce the behavior: 1. Go to '...' @@ -19,16 +21,20 @@ Steps to reproduce the behavior: 4. See error # Expected Behavior + A clear and concise description of what you expected to happen. # Screenshots + If applicable, add screenshots to help explain your problem. # System Information - - System: [e.g. PC or iPhone11, ...] - - OS: [e.g. iOS] - - Browser [e.g. chrome, safari] - - KarakaVersion [e.g. 22] + +- System: [e.g. PC or iPhone11, ...] +- OS: [e.g. iOS] +- Browser [e.g. chrome, safari] +- KarakaVersion [e.g. 22] # Additional Information + Add any other context about the problem here. diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 5789ee7..d52ab98 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -93,7 +93,7 @@ final class ApiController extends Controller // is allowed to read if (!$this->app->accountManager->get($accountId)->hasPermission(PermissionType::READ, $this->app->unitId, null, self::NAME, PermissionCategory::REPORT, $template->getId()) - || ($isExport && !$this->app->accountManager->get($accountId)->hasPermission(PermissionType::READ, $this->app->unitId, $this->app->appName, self::NAME, PermissionCategory::EXPORT)) + || ($isExport && !$this->app->accountManager->get($accountId)->hasPermission(PermissionType::READ, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::EXPORT)) ) { $response->header->status = RequestStatusCode::R_403; @@ -124,7 +124,7 @@ final class ApiController extends Controller private function validateExport(RequestAbstract $request) : array { $val = []; - if (($val['id'] = empty($request->getData('id')))) { + if (($val['id'] = !$request->hasData('id'))) { return $val; } @@ -466,7 +466,7 @@ final class ApiController extends Controller new AccountPermission( $request->header->account, $this->app->unitId, - $this->app->appName, + $this->app->appId, self::NAME, self::NAME, PermissionCategory::TEMPLATE, @@ -494,7 +494,7 @@ final class ApiController extends Controller private function validateTemplateCreate(RequestAbstract $request) : array { $val = []; - if (($val['name'] = empty($request->getData('name'))) + if (($val['name'] = !$request->hasData('name')) || ($val['files'] = empty($request->getFiles())) ) { return $val; @@ -616,7 +616,7 @@ final class ApiController extends Controller new AccountPermission( $request->header->account, $this->app->unitId, - $this->app->appName, + $this->app->appId, self::NAME, self::NAME, PermissionCategory::REPORT, @@ -644,7 +644,7 @@ final class ApiController extends Controller private function validateReportCreate(RequestAbstract $request) : array { $val = []; - if (($val['template'] = empty($request->getData('template'))) + if (($val['template'] = !$request->hasData('template')) ) { return $val; } diff --git a/tests/ControllerTestTemp.php b/tests/ControllerTestTemp.php index 5608d81..6b77e52 100755 --- a/tests/ControllerTestTemp.php +++ b/tests/ControllerTestTemp.php @@ -59,7 +59,7 @@ class ControllerTest extends \PHPUnit\Framework\TestCase $permission = new AccountPermission(); $permission->setUnit(1); - $permission->setApp('backend'); + $permission->setApp(2); $permission->setPermission( PermissionType::READ | PermissionType::CREATE