From bacb3dc85e4e0b31fecb190f1f16815da05790b9 Mon Sep 17 00:00:00 2001 From: iglocska Date: Wed, 24 Nov 2021 01:50:55 +0100 Subject: [PATCH] fix: [API] fixed broken API - don't call functions specifically meant for the UI when in an ACL context - also fixed breaking issues with the logging --- src/Controller/AppController.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Controller/AppController.php b/src/Controller/AppController.php index 46c5355..cdd85e2 100644 --- a/src/Controller/AppController.php +++ b/src/Controller/AppController.php @@ -113,8 +113,10 @@ class AppController extends Controller $this->ACL->setUser($user); $this->request->getSession()->write('authUser', $user); $this->isAdmin = $user['role']['perm_admin']; - $this->set('menu', $this->ACL->getMenu()); - $this->set('loggedUser', $this->ACL->getUser()); + if (!$this->ParamHandler->isRest()) { + $this->set('menu', $this->ACL->getMenu()); + $this->set('loggedUser', $this->ACL->getUser()); + } } else if ($this->ParamHandler->isRest()) { throw new MethodNotAllowedException(__('Invalid user credentials.')); } @@ -153,9 +155,8 @@ class AppController extends Controller if (!empty($authKey)) { $this->loadModel('Users'); $user = $this->Users->get($authKey['user_id']); - $user = $logModel->userInfo(); $logModel->insert([ - 'action' => 'login', + 'request_action' => 'login', 'model' => 'Users', 'model_id' => $user['id'], 'model_title' => $user['username'], @@ -167,7 +168,7 @@ class AppController extends Controller } else { $user = $logModel->userInfo(); $logModel->insert([ - 'action' => 'login', + 'request_action' => 'login', 'model' => 'Users', 'model_id' => $user['id'], 'model_title' => $user['name'],