我开始使用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时,它会自动重定向到users / login anh show message net controller usercontroller。我该如何解决,P001是我的登录页面
答案 0 :(得分: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()。