我正在使用 cakephp auth 插件。 登录后发生的事情是。 默认登录页面是通过在 UsersController 或 AppController 的 beforeFilter 函数中定义 loginAction 变量来设置的。 但是,如果您在应用程序中使用了插件,并且用户尝试访问插件的 Controller 操作,则用户将被重定向到像这样的无效页面。
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');
}
最佳答案
$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');
那里。
关于CakePHP 身份验证插件重定向问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9199348/