Question

In my controller I have a preDispatch method where I check if the user is logged in. If he is not I redirect the user to login form.

Is there any way to disable one of the action's from the preDispatch method? Because I do not need the authorisation for this action.

Was it helpful?

Solution

In the plugin, you can check if that specific controller and action is being called and allow the request to continue.

Something similar to the following in your plugin will work.

public function preDispatch(Zend_Controller_Request_Abstract $request) {
    // ...

    $controller = $request->getControllerName();
    $action     = $request->getActionName();

    if ($controller == 'login' && $action == 'login') {
        return ; // do not execute any more plugin code
    }

    // deny access and redirect to login form

OTHER TIPS

I usually use my "Empty" controller/action to do this :

public function preDispatch(Zend_Controller_Request_Abstract $request) {
if (!$logined){
 $request->setControllerName('empty')->setActionName('index');
return;
}
}

It substitute your current action.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top