I should show an error/error
instead of a an error/denied action
in case of /nonexistentcontroller
I ended up with this code
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$response = $this->getResponse();
if($response->isException()){
$this->_request->setModuleName('default');
$this->_request->setControllerName('error');
$this->_request->setActionName('error');
return null;
}
$auth = Zend_Registry::get('auth');
$this->_roleName =
($auth->hasIdentity())?$auth->getIdentity()->role:'guest';
$resourceName = '';
if ($request->getModuleName() != 'default') {
$resourceName .= $request->getModuleName() . ':';
}
$resourceName .= $request->getControllerName();
/** Check if the controller/action can be accessed by the current
user */
if (!$this->getAcl()->isAllowed($this->_roleName, $resourceName,
$request->getActionName())) {
/** Redirect to access denied page */
$this->denyAccess();
}
}
Is it the right way ?
Thanks in advance.
Bye
--
View this message in context: http://n4.nabble.com/Zion-Acl-show-error-action-404-instead-of-denied-action-tp964700p964700.html
Sent from the Zend MVC mailing list archive at Nabble.com.
没有评论:
发表评论