views:

96

answers:

1

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

+1  A: 

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');
    }
}
zwip
i havent tried this solution, but i think it will work, except that i did not define acl rules for non protected page. so i think the solution i might use is: `if (!acl->has('xxx')) { return true }`. this way, the request will continue to be processed and likely result in a 404
jiewmeng
hey wait a min! i actually already have this setup, thats why it looks so familiar, that check, checks the resource, the action is in the privilege, and that is where the problem lies now.
jiewmeng
You could also try to modify your ErrorController to catch and redirect an access denied error to your 404 view.
zwip