Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    • CommentAuthoroisucf
    Hello All,

    Does anyone know the "correct" was to have different routes based on admin role?

    For example if a User login in with a role of an "Application owner" or "Administrator" they would go to the dashboard controller. If a User login has role of "Registered user" they would would be routed to a different controller instead.

    • CommentAuthorhaakon

    Just do a redirect in your login code

    • CommentAuthorpogeybait4883
    In the following example of a controller, if a user tries to load the 'index' action, the _getRole beforeFilter will fire first and determine if the user is an administrator or a registered user and set the controller variable 'isAdministrator'. Then the _redirectByRole beforeFilter will fire (notice it is set to fire only on the index action) and redirect the user to the appropriate controller and action. Hope this helps.

    var $isAdministrator = false;
    '_redirectByRole' => array(
    'only' => array(

    function index() {}

    function _getRole() {
    //Check if the user is an administrator or registered user and set $this->isAdministrator to true or false

    function _redirectByRole() {
    if($this->isAdministrator) {
    'controller' => 'admincontroller',
    'action' => 'adminaction'
    'controller' => 'usercontroller',
    'action' => 'useraction'