I'm new to CakePHP. I'm trying [the Cake cookbook tutorial of simple authentication](http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html) with CakePHP 2.4.1.  

I'm always getting "Invalid username or password, try again" although I typed the correct username and password.

```
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'));
    }
}

```

According to [the AuthComponent API](http://api.cakephp.org/2.4/class-AuthComponent.html#_login), if the parameter to `Auth->login()` is empty or not specified, the request will be used to identify a user.
The debugging query output shows

```
SELECT `User`.`id`, `User`.`username`, `User`.`password`, `User`.`role`, `User`.`created`, `User`.`modified` 
FROM `cake_dvdcatalog`.`users` AS `User` WHERE `User`.`username` = 'admin' LIMIT 1

```

Here is my User model:

```
// app/Model/User.php
App::uses('AuthComponent', 'Controller/Component');

class User extends AppModel {

    public $validate = array(
        'username' => array(
            'required' => array(
                'rule' => array('notEmpty'),
                'message' => 'A username is required'
            )
        ),
        'password' => array(
            'required' => array(
                'rule' => array('notEmpty'),
                'message' => 'A password is required'
            )
        ),
        'role' => array(
            'valid' => array(
                'rule' => array('inList', array('admin', 'author')),
                'message' => 'Please enter a valid role',
                'allowEmpty' => false
            )
        )
    );

    public function beforeSave($options = array()) {
        if (isset($this->data[$this->alias]['password'])) {
            $this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']);
        }
        return true;
    }
}

```