Я пытаюсь создать новый регистр и страницу входа. У меня проблема с логином.
1) После того, как я зарегистрировал имя пользователя и пароль, он успешно хэширован и сохранен в БД, пожалуйста, найдите коды ниже: (все согласно правилам торта)
User.php:
<?php
App::uses('AuthComponent', 'Controller/Component');
class User extends AppModel {
......
public function beforeSave() {
if (isset($this->data[$this->alias]['password'])) {
$this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']);
}
return true;
}
}
?>
UsersController.php:
public function add() {
if ($this->request->is('post')) {
$this->User->create();
if ($this->User->saveAll($this->request->data)) {
$this->Session->setFlash(__('The user has been saved'));
$this->redirect(array('controller' => 'Posts','action' => 'index'));
} else {
$this->Session->setFlash(__('The user could not be saved. Please, try again.'));
}
}
}
public function login() {
if ($this->Auth->login()) {
$this->redirect($this->Auth->redirect());
} else {
$this->Session->setFlash(__('Invalid username or password, try again'), 'default', array(), 'auth');
}
}
public function logout() {
$this->redirect($this->Auth->logout());
}
login.ctp:
<fieldset>
<?php echo $this->Session->flash('auth'); ?>
</fieldset>
<?php echo $this->Form->create('Users');?>
<fieldset>
<?php
echo $this->Form->input('username');
echo $this->Form->input('password');
?>
</fieldset>
<?php echo $this->Form->end(__('Login'));?>
Debug: (отладка ($ this-> data);)
Из AppController:
Array
(
[Users] => Array
(
[username] => vinodronold
[password] => vinodronold
)
)
Из UsersController:
Array
(
[Users] => Array
(
[username] => vinodronold
[password] => vinodronold
)
)
Проблема:
Всякий раз, когда я получаю доступ к / Users / логину URL, я получаю сообщение «Неверное имя пользователя или пароль, попробуйте еще раз».
Также я не могу войти, хотя я ввожу правильное имя пользователя и пароль.
Пожалуйста, помогите.
Заранее спасибо !!!