2012-02-08 144 views
4

我正在使用cakephp auth插件。 登录后发生了什么。 默认的登录页面是通过在UsersController或AppController的beforeFilter函数中定义loginAction变量来设置的。 但是,如果您在应用程序中使用了插件,并且用户尝试访问插件的控制器操作,则用户将被重定向到这样的无效页面。CakePHP auth插件重定向问题

http://satyam.vakharia.com/plugin_name/users/login

BeforeFilter功能是这样的..

function beforeFilter() { 
Security::setHash('md5'); 
$this->Auth->loginAction = array('controller' => 'users', 'action' => 'login'); 
$this->Auth->loginRedirect = array('controller' => 'home', 'action' => 'index'); 
$this->Auth->loginError = 'Invalid Username or Password.'; 
$this->Auth->authError = "You are not authorized to access."; 
$this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login'); 

}

回答

5
$this->Auth->loginAction = array('plugin' => false, 'controller' => 'users', 'action' => 'login'); 
$this->Auth->loginRedirect = array('plugin' => false, 'controller' => 'home', 'action' => 'index'); 
$this->Auth->loginError = 'Invalid Username or Password.'; 
$this->Auth->authError = "You are not authorized to access."; 
$this->Auth->logoutRedirect = array('plugin' => false, 'controller' => 'users', 'action' => 'login'); 

有。

+0

为您工作? – 2012-02-08 18:54:39

+0

我必须添加的一件事是'plugin'=> false? – NovusMobile 2012-02-09 07:06:32

+0

是的,尝试那应该解决您的问题 – 2012-02-09 07:30:53