0

我从 cakephp 框架开始,我使用 auth 创建登录表单,在我的 appcontroller 中添加:

class AppController extends Controller {
    public $components = array('Auth', 'Cookie');
    public function beforeFilter(){
        $this->Auth->authenticate = array(
                'Form' => array(
                    'userModel' => 'User',
                    'fields' => array('name' => 'name', 'password' => 'password'),
                )
            );
            $this->Auth->loginAction = array('controller' => 'TestOnlineSystem', 'action' => 'P001');
            $this->Auth->loginRedirect = array('controller' => 'TestOnlineSystem', 'action' => 'index');
            $this->Auth->loginError = 'Failed to login';
            $this->Auth->authError = ' ';           
    }   
}

但是当我运行 TestOnlineSystem/P001 时,它会自动重定向到用户/登录 anh 显示消息网络控制器用户控制器。我该如何解决它,P001 是我的登录页面

4

1 回答 1

0

我同意 thaJeztah,尝试来自http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html的标准配置:

public $components = array(
    'Auth' => array(
        'loginAction' => array(
            'controller' => 'TestOnlineSystem',
            'action' => 'P001',
            'plugin' => 'users'
        )
    )
);

并摆脱你的 beforeFilter()。

于 2013-03-16T02:04:23.143 回答