AuthBackendController: Add final indexAction

Required to automatically redirect to the first permitted list action.

refs #8826
This commit is contained in:
Johannes Meyer 2015-06-02 11:59:04 +02:00
parent 00c31ffd28
commit 7213379cac
4 changed files with 18 additions and 17 deletions

View File

@ -84,7 +84,7 @@ class ConfigController extends Controller
public function indexAction()
{
if ($this->firstAllowedAction === null) {
throw new SecurityException($this->translate('No permission for configuration'));
throw new SecurityException($this->translate('No permission for application configuration'));
}
$action = $this->getTabs()->get($this->firstAllowedAction);
if (substr($action->getUrl()->getPath(), 0, 7) === 'config/') {

View File

@ -17,14 +17,6 @@ use Icinga\Web\Widget;
class GroupController extends AuthBackendController
{
/**
* Redirect to this controller's list action
*/
public function indexAction()
{
$this->redirectNow('group/list');
}
/**
* List all user groups of a single backend
*/

View File

@ -17,14 +17,6 @@ use Icinga\Web\Widget;
class UserController extends AuthBackendController
{
/**
* Redirect to this controller's list action
*/
public function indexAction()
{
$this->redirectNow('user/list');
}
/**
* List all users of a single backend
*/

View File

@ -9,6 +9,7 @@ use Icinga\Authentication\User\UserBackend;
use Icinga\Authentication\User\UserBackendInterface;
use Icinga\Authentication\UserGroup\UserGroupBackend;
use Icinga\Authentication\UserGroup\UserGroupBackendInterface;
use Icinga\Security\SecurityException;
use Icinga\Web\Controller;
/**
@ -16,6 +17,22 @@ use Icinga\Web\Controller;
*/
class AuthBackendController extends Controller
{
/**
* Redirect to the first permitted list action
*/
final public function indexAction()
{
if ($this->hasPermission('config/authentication/users/show')) {
$this->redirectNow('user/list');
} elseif ($this->hasPermission('config/authentication/groups/show')) {
$this->redirectNow('group/list');
} elseif ($this->hasPermission('config/authentication/roles/show')) {
$this->redirectNow('role/list');
} else {
throw new SecurityException($this->translate('No permission for authentication configuration'));
}
}
/**
* Return all user backends implementing the given interface
*