2013-03-15 30 views
0

我与CakePHP的框架开始,我使用身份验证来创建一个登录形式,在我的AppController我补充一下:CakePHP的:认证介绍功能自动定向到用户/密码

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显示消息net controller usercontroller。我怎样才能修复它,P001是我的登录页面

+1

只是想知道(不知道这是否有所作为);为什么要在'beforeFilter()'中执行所有这些设置,而不仅仅是在手册中描述的'$ components'数组内部? (http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#configuring-authentication-handlers)。 – thaJeztah 2013-03-15 16:46:36

+0

用于思考控制器名称的外部约定......哦,等等......) – Dave 2013-03-15 19:04:06

+0

(请说明:“...显示消息网络控制器用户控制器。” – Dave 2013-03-15 19:07:37

回答