chg: [appcontroller] minor changes

- getRoleAccess now returns array format
- moved setting of view variables behind a rest check, to avoid additional unused actions for API queries
- current user's role access matrix passed to view via "roleAccess"
pull/79/head
iglocska 2021-12-01 14:23:27 +01:00
parent fbb1a52724
commit e408f29a05
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
1 changed files with 15 additions and 12 deletions

View File

@ -116,6 +116,7 @@ class AppController extends Controller
if (!$this->ParamHandler->isRest()) {
$this->set('menu', $this->ACL->getMenu());
$this->set('loggedUser', $this->ACL->getUser());
$this->set('roleAccess', $this->ACL->getRoleAccess(false, false));
}
} else if ($this->ParamHandler->isRest()) {
throw new MethodNotAllowedException(__('Invalid user credentials.'));
@ -131,6 +132,7 @@ class AppController extends Controller
}
$this->ACL->checkAccess();
if (!$this->ParamHandler->isRest()) {
$this->set('breadcrumb', $this->Navigation->getBreadcrumb());
$this->set('ajax', $this->request->is('ajax'));
$this->request->getParam('prefix');
@ -145,6 +147,7 @@ class AppController extends Controller
$this->set('metaGroup', !empty($this->isAdmin) ? 'Administration' : 'Cerebrate');
}
}
}
private function authApiUser(): void
{
@ -191,6 +194,6 @@ class AppController extends Controller
public function getRoleAccess()
{
return $this->RestResponse->viewData($this->ACL->getRoleAccess());
return $this->RestResponse->viewData($this->ACL->getRoleAccess(false, false));
}
}