Там у меня есть две таблицыCakePHP 2: 4: AuthComponent не работает
1) aucusers 2) user_types
Для использования Идента компонента Я сильфон кода в 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