cakephp错误:用户名和密码无效,请重试

cakephp错误:用户名和密码无效,请重试,cakephp,Cakephp,我坚持认为我的cakephp登录不起作用。我正在创建登录并在同一视图上注册。期待帮助。这是我的代码 public function login(){ (isset($this->request->data['User'])) { // Check if the login Form was submitted if (!empty($this->request->data['User']) &&

我坚持认为我的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'));
}
}

此函数的模型是

    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'); ?>

首先在数据库中使用加密表单密码。密码存储在数据库中加密。试试看:我已经这样做了,兄弟,我是这个cakephp的新手,所以我想我遗漏了一些东西。面对同样的问题,你找到解决方案了吗?它在白色浏览器页面中返回“false”,而不进入索引页面。是$this->request->data['User'具有用户名和密码的值?(设置($this->request->data['User']){//检查登录表单是否已提交($this->Auth->login($this->request->data['User']){返回$this->redirect($this->Auth->redirect());}如果它不工作,你必须检查你的应用程序控制器。它还没有工作。我正在添加上面是我的应用程序控制器,你可以看看它吗。
 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'
            )
        )
    )
);
<?php
App::uses('BlowfishPasswordHasher', 'Controller/Component/Auth');

class User extends AppModel {

    public function beforeSave($options = array()) {


            $passwordHasher = new BlowfishPasswordHasher();
            $this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password']);

        return true;
    }
}