CakePHP auth插件重定向问题

时间:2012-02-08 18:34:53

标签: cakephp authentication before-filter

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

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');

}

1 个答案:

答案 0 :(得分: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');