2008年10月14日星期二

Re: [fw-mvc] Plugin and Redirector

-- angelbit <angelbit88@gmail.com> wrote
(on Tuesday, 14 October 2008, 04:45 PM +0200):
> I created a plugin to redirect the login page if dont are
> authenticated.Now rather than redirect generates an infinite loop and
> end with timeout.How can I do?

Make sure the plugin does not redirect when the controller is 'user' and
the action is 'login'. ;)

> The code:
>
>> class PluginAuth extends Zend_Controller_Plugin_Abstract {
>>
>> function routeStartup() {
>>
>>
>>
>> $auth = Zend_Auth::getInstance();
>> if (!$auth->hasIdentity()) {
>>
>>
>> $re =
>> Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
>> $re->setgotoUrl('/user/login/');
>> $re->gotoUrl();
>> }
>>
>> }
>>
>>
>>
>>
>> }
> PS:sorry for my english are italian
>

--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/

没有评论: