0
據我可以告訴一切儘可能創建一個用戶(在我的情況下人)用戶名和密碼工作正常。當我查看db表時,密碼被散列並且用戶名被保存。發生以下問題的天氣我散列密碼,或不那麼我認爲這個問題是無論是在AppController中或把PeopleControllercakephp 2.3.6登錄問題與驗證組件
AppController的
class AppController extends Controller {
public $components = array(
'DebugKit.Toolbar',
'Session',
'Auth'=>array(
'loginAction'=>array(
'controller'=> 'people',
'action'=> 'login'),
'loginRedirect'=>array(
'controller'=>'people', 'action'=>'index'),
'logoutRedirect'=>array(
'controller'=>'people', 'action'=>'index'),
'authError'=>"You can't access that page",
'authorize'=>array('Controller')
)
);
public function isAuthorized($people)
{
return true;
}
public function beforeFilter()
{
$this->Auth->allow('index','view');
}
}
,並把PeopleController
class PeopleController extends AppController
{
public $helpers = array('Html', 'form', 'Js');
public $components = array('RequestHandler');
public function beforeFilter()
{
parent::beforeFilter();
$this->Auth->allow('create');
}
public function login()
{
if ($this->request->is('post')) {
if ($this->Auth->login()) {
return $this->redirect($this->Auth->redirectURL());
}
else {
$this->Session->setFlash('Your username/password combination was incorrect');
}
}
}
public function logout()
{
$this->redirect($this->Auth->logout());
}
public function index() {
}
,當我嘗試登錄我一直得到的用戶名和密碼不匹配閃存消息,即使我是積極的我正在輸入正確的細節,任何想法如何排除故障拍攝這個讚賞
login.ctp
<h2>Login</h2>
<?php
echo $this->Form->create();
echo $this->Form->input('username');
echo $this->Form->input('password');
echo $this->Form->end('Login');
?>
打開調試,看看它正在運行的MySQL查詢。你應該能夠看到它試圖在數據庫中匹配什麼 – chrislondon
謝謝,它似乎是發送正確的數據與正確的字段名稱,但在SQL日誌中說'警告沒有活動的數據庫連接',所以我猜這是問題。我想我已經在某個地方輸入了錯誤的名字,但是如果你知道我應該在哪裏看到那將會很有幫助 – Ir1sh
debugkit會話信息如下所示:Message> auth> message youcant access that page,element default,paramsn(empty)and Message>閃光燈>消息您的用戶名和密碼組合不正確,elemnt默認,參數爲空。對我來說,它看起來像是導致autherror函數觸發,導致peoplecontroller中的else觸發,所以它必須是從模型到導致autherror觸發的數據庫的事情?這聽起來合理嗎? – Ir1sh