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
pull/79/head
iglocska 2021-11-24 01:50:55 +01:00
parent 92fee87a7f
commit bacb3dc85e
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
1 changed files with 6 additions and 5 deletions

View File

@ -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'],