CakePHP 身份验证插件重定向问题

标签 cakephp authentication before-filter

我正在使用 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/

相关文章:

php - CakePHP : How can I catch mkdir error?

php - 在 Linux 上安装 CakePHP 时出现问题

php - Cakephp 2 在多个部分获取数据的问题

java - OpenSAML 如何检查 SAML 响应(签名/证书)是否确实来 self 的 IDP?

php - 添加验证码到 Symfony2 登录

ruby-on-rails - Rails从before_filter方法中设置布局

ruby-on-rails - rails : prepend_before_action in superclass

CakePHP 使用 Auth 组件通过用户名或电子邮件登录

ruby-on-rails - token 和摘要有什么区别?

ruby - 多个 Controller 之间共享的 before_filter 放在哪里