> Hi all,
>
> I'm writing an auth plugin that should redirect the user to the login
> page if she is not logged in. After the call to
> Zend_Controller_Action_Helper_Redirector::gotoUrl the controller
> action gets called anyway.
> Calling gotoUrlAndExit() is not an options since it will kill the unit
> tests interpreter.
>
> I dug into the code, but couldn't find a way to stop the action from
> being called.
>
> Regards
>
>
Hi, this is the Way I did:
class My_Plugin_AccessControl extends Zend_Controller_Plugin_Abstract
{
public function dispatchLoopStartup(Zend_Controller_Request_Abstract
$request)
{
if (!Zend_Auth::getInstance()->hasIdentity()) {
$request->setModuleName('user')->setControllerName('auth')->setActionName('login')->setDispatched(true);
}
}
}
Benjamin
没有评论:
发表评论