0
有我有兩個表CakePHP的2:4:Authcomponent不工作
1)aucusers 2)user_types
對於使用AUTH組分I中的AppController
public $components = array('Session','RequestHandler','Paginator'=>array('limit'=>4),'Auth'=>array(
'loginAction' => array(
'controller' => 'aucusers',
'action' => 'login'
),
'loginRedirect' => array('controller' => 'aucusers','action' => 'add'),
'logoutRedirect' => array('controller' => 'aucusers','action' => 'add'),
'authError'=>'You can not access this page!!',
));
public function beforeFilter() {
$this->set('logged_in', $this->Auth->loggedIn());
$this->set('current_user',$this->Auth->user());
parent::beforeFilter();
$this->Paginator->settings = array(
'limit'=>4
);
在模型中使用波紋管代碼我已經使用了哈希密碼
public function beforeSave($options = array()) {
if (isset($this->data[$this->alias]['password'])) {
$passwordHasher = new SimplePasswordHasher();
$this->data[$this->alias]['password'] = $passwordHasher->hash(
$this->data[$this->alias]['password']
);
}
return true;
}
在aucusers co ntroller我有加
public function login() {
if ($this->request->is('post')) {
if ($this->Auth->login()) {
return $this->redirect($this->Auth->redirect());
}
$this->Session->setFlash(__('Invalid username or password, try again'));
}
}
public function logout() {
return $this->redirect($this->Auth->logout());
}
添加後
$this->Auth->allow()
我已經當我去登錄,它顯示我
無效的用戶名或密碼user.But,再試一次。
一個卑鄙的手段來檢查您的密碼哈希函數是設置正確 - 在core.php中設置調試到2那麼當你嘗試登錄(和失敗)查看中使用的哈希SQL轉儲。將它與數據庫中的散列進行比較。它是一樣的嗎? – robmcvey