From 9eb8b8e7d6d66fdf3f951df955b8294782fa25cf 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 ++++++++++---- Application/Timerecording/Application.php | 14 +++++--------- Application/Timerecording/js/timerecording.js | 4 +++- Controller/ApiController.php | 6 +++--- 4 files changed, 21 insertions(+), 17 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/Application/Timerecording/Application.php b/Application/Timerecording/Application.php index 84001d4..88d2710 100755 --- a/Application/Timerecording/Application.php +++ b/Application/Timerecording/Application.php @@ -178,18 +178,14 @@ final class Application if (!($account instanceof NullAccount)) { $response->header->l11n = $account->l11n; - } elseif ($this->app->sessionManager->get('language') !== null) { + } elseif ($this->app->sessionManager->get('language') !== null + && $response->header->l11n->getLanguage() !== $this->app->sessionManager->get('language') + ) { $response->header->l11n ->loadFromLanguage( $this->app->sessionManager->get('language'), $this->app->sessionManager->get('country') ?? '*' ); - } elseif ($this->app->cookieJar->get('language') !== null) { - $response->header->l11n - ->loadFromLanguage( - $this->app->cookieJar->get('language'), - $this->app->cookieJar->get('country') ?? '*' - ); } UriFactory::setQuery('/lang', $response->getLanguage()); @@ -212,7 +208,7 @@ final class Application } /* No reading permission */ - if (!$account->hasPermission(PermissionType::READ, $this->app->unitId, $this->app->appName, 'Dashboard')) { + if (!$account->hasPermission(PermissionType::READ, $this->app->unitId, $this->app->appId, 'Dashboard')) { $this->create403Response($response, $pageView); return; @@ -226,7 +222,7 @@ final class Application $request->uri->getRoute(), $request->getDataString('CSRF'), $request->getRouteVerb(), - $this->app->appName, + $this->app->appId, $this->app->unitId, $account, $request->getData() diff --git a/Application/Timerecording/js/timerecording.js b/Application/Timerecording/js/timerecording.js index dfbf7bf..b81da07 100755 --- a/Application/Timerecording/js/timerecording.js +++ b/Application/Timerecording/js/timerecording.js @@ -47,7 +47,9 @@ export class Application { this.request.setRootPath( HttpUri.parseUrl( - document.getElementsByTagName('base')[0].href + typeof document.getElementsByTagName('base')[0] !== 'undefined' + ? document.getElementsByTagName('base')[0].href + : '' ).path ); diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 3cc9fac..5bed01d 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -57,7 +57,7 @@ final class ApiController extends Controller public function apiSessionCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void { if ($request->hasData('account') && !$this->app->accountManager->get($request->header->account)->hasPermission( - PermissionType::CREATE, $this->app->unitId, $this->app->appName, self::NAME, PermissionCategory::SESSION_FOREIGN + PermissionType::CREATE, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::SESSION_FOREIGN )) { $response->header->status = RequestStatusCode::R_403; @@ -153,7 +153,7 @@ final class ApiController extends Controller if ($request->hasData('account') && ((int) $request->getData('account')) !== $request->header->account ) { if (!$this->app->accountManager->get($request->header->account)->hasPermission( - PermissionType::CREATE, $this->app->unitId, $this->app->appName, self::NAME, PermissionCategory::SESSION_ELEMENT_FOREIGN + PermissionType::CREATE, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::SESSION_ELEMENT_FOREIGN )) { $response->header->status = RequestStatusCode::R_403; @@ -195,7 +195,7 @@ final class ApiController extends Controller private function validateSessionElementCreate(RequestAbstract $request) : array { $val = []; - if (($val['session'] = empty($request->getData('session')) || !\is_numeric($request->getData('session')))) { + if (($val['session'] = !$request->hasData('session') || !\is_numeric($request->getData('session')))) { return $val; }