Hello all !

I have a problem with the preDispatch method : 

To check for authentication and authorization I created my own parent class
for all controllers (and for other common code). 
And this parent class extends Zend_Controller_Action.

I call in each controller the method preDispatch of the parent class I
created.

        function preDispatch() {
                parent::preDispatch();
                echo 'other instructions here';
        }

When the parent finds bad auth or acl rights, it forwards to the login page.

The problem is that the instructions in the controllor below the parent call
are still executed.
E.G. in my code above the "other instructions here" string is displayed on
the screen.

If the auth and/or ACL rights are wrong, these instructions shouldn't be
executed and I expect just a forward to the login page.

This is the code of the parent preDispath method :

    public function preDispatch()
    {
        $this->view->baseUrl = $this->_request->getBaseUrl();
                
        $auth = Zend_Auth::getInstance();
        $acl = Zend_Registry::get('acl');
                
        if ( ! $auth->hasIdentity() ) {
                $this->view->errorLogin = "You must be authenticated to view 
this page.";
                $this->_forward('index','auth');
                return;
        }
        
        if ( ! $acl->isAllowed($auth->getIdentity()->type, 'partnerModule') ) {
                $this->view->errorLogin = "You are not allowed to view this 
page.";
                $this->_forward('index','auth');
                return;
        }
    }

Thank you for any kind help ! 
-- 
View this message in context: 
http://www.nabble.com/question-about-preDispatch-tf4540709s16154.html#a12959128
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to