Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zend Framework: preDispatch ACL plugin causes requests to non existent page to Access Denied instead of 404

i have setup a preDispatch plugin for my ACL. i have used the controller as resource, action as privilege. when i try to goto a non existent page, i get to the access denied page instead of 404, i think because the resource and privilege are queried and since they are not found, it goes to the access denied page...

how can i fix this? maybe my method of implementing the plugin was wrong? can i somehow have the check for a existent resource b4 my acl plugin runs? \

update

plugin code @pastebin

like image 315
Jiew Meng Avatar asked Aug 06 '10 07:08

Jiew Meng


1 Answers

I had the same issue and added this to the preDispatch function (using modules though, but it's the $acl->has() function that is interesting):

if (!$acl->has($request->module . '_' . $request->controller)) {
    // action/resource does not exist in ACL
    $request->setModuleName('default');
    $request->setControllerName('error');
    $request->setActionName('notfound');
} else {
    // resource does exist, check ACL
    if (!$acl->isAllowed($role, $module . '_' . $controller, $action)) {
        $request->setControllerName('user');
        $request->setActionName('login');
    }
}
like image 170
zwippie Avatar answered Sep 19 '22 13:09

zwippie