你好,我是新來cakephp 我的問題是$this->Auth->login($this->request->data)
總是返回true,我不知道它是否有什麼關係與表名稱,我的表名稱是「管理員」而不是「用戶」,它接受任何密碼,事情真的是錯誤的。登錄cakephp不工作我沒有(管理員)表而不是(用戶)
這裏是我的登錄功能:
public function login()
{
$this->layout = 'login';
if ($this->request->is('post'))
{
if ($this->Auth->login())
{
return $this->redirect($this->Auth->redirect());
}
else
{
$this->Session->setFlash(__('Username or password is incorrect'));
}
}
}
我把該功能是here這不是在在所有
登錄我的舊代碼爲:
public function login()
{
$this->layout = 'login';
if(!$this->Session->read('Auth.User'))
{
debug($this->Session->read('Auth.User'));
if ($this->request->is('post'))
{
debug($this->Auth->login());
//$this->pa($this->request->data);
if ($this->Auth->login())
{
$this->Admin->id = $this->Session->read('Auth.Admin.id');
$this->redirect($this->Auth->redirect());
}
else
{
$this->Session->setFlash(__('Username or password is incorrect'));
}
}
}
else
{
return $this->redirect($this->Auth->redirect());
}
}
它不工作太
請註明您的確切的CakePHP版本,相應地標記您的問題,並根據所閱讀的版本** http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#identifying-users-and-logging-them-在** – ndm
我的cakephp版本是:2.4.4 –
只能用 $ this-> Auth-> login(); 它的自動驗證 –