Я застрял в этом, что мой вход в cakephp не работает. Я создаю логин и регистрацию на том же самом представлении. Ждем помощи. Здесь мой код.ошибка cakephp: неверное имя пользователя и пароль, попробуйте еще раз
public function login(){
(isset($this->request->data['User'])) { // Check if the login Form was submitted
if (!empty($this->request->data['User']) && $this->Auth->login()) {
return $this->redirect($this->Auth->redirect());
}
$this->request->data['User']['password'] = '';
$this->Session->setFlash(__('Invalid username or password, try again'));
}
}
Модели для этого fiunction является
class User extends AppModel{
public $validate = array(
'email'=>'email',
'password' => array(
'required' => array(
'rule' => array('notEmpty'),
'message' => 'A password is required'
)
),);
вида является:
<div><?php echo $this->Session->flash(); ?></div>
<?php echo $this->Form->create("User"); ?>
<?php echo $this->Form->input('email' ,array('label'=>"Email :")); ?>
<?php echo $this->Form->input('password',array('label'=>"Password"));?>
<?php echo $this->Form->end('Login'); ?>
Хэша пароль правильно savig в базе данных, используя регистрацию, но когда я введите пароль при входе в систему, он выдаст неверное имя пользователя и пароль. Мой AppController является
class AppController extends Controller {
public $components = array(
'Auth'=> array(
'authenticate' => array(
'Form' => array(
'fields' => array('username' =>'email','password'=>'password')
)
)
),
'Session',
'Auth' => array(
'loginRedirect' => array(
'controller' => 'users',
'action' => 'profileindex'
),
//'authorize' => array('Controller'),
'loginAction' => array('controller' => 'users', 'action' => 'login'),
'loginRedirect' => array('controller' => 'users', 'action' => 'profileindex'),
'logoutRedirect' => array('controller' => 'users', 'action' => 'login'),
'authError' => 'You don\'t have access here.',
'logoutRedirect' => array(
'controller' => 'users',
'action' => 'login',
'home'
),
'authenticate' => array(
'Form' => array(
'passwordHasher' => 'Blowfish'
)
)
)
);
Прежде всего зашифрованной форме пароля в базе данных. –
пароль зашифрован в базе данных. –
Попробуйте: http://book.cakephp.org/2.0/ru/tutorials-and-examples/blog-auth-example/auth.html –