title: CakePHP 2.4 Auth->login() always return FALSE
body: <p>I am working on a simple login application with cake 2.4 for my mom. here is the code for User model.</p>
  
  <pre><code>App::uses('SimplePasswordHasher', 'Controller/Component/Auth');
  
  class User extends AppModel{
          public $validate = array(
                  'username' =&gt; array(
                          'required' =&gt; array(
                                  'rule' =&gt; array('notEmpty'),
                                  'message' =&gt; 'A username is required'
                          )
                  ),
                  'password' =&gt; array(
                          'required' =&gt; array(
                                  'rule' =&gt; array('notEmpty'),
                                  'message' =&gt; 'A password is required'
                          )
                  )
          );
  
          public function beforeSave($options = array()) {
                  if(isset($this-&gt;data[$this-&gt;alias]['password'])) {
                          $passwordHasher = new SimplePasswordHasher();
                          $this-&gt;data[$this-&gt;alias]['password'] = $passwordHasher-&gt;hash(
                          $this-&gt;data[$this-&gt;alias]['password']
                          );
                  }
                  return true;
          }
  }
  </code></pre>
  
  <p>My UsersController code is...</p>
  
  <pre><code>class UsersController extends AppController{
          public $helpers = array('Html','Form');
  
          public function beforeFilter(){
                  parent::beforeFilter();
                  $this-&gt;Auth-&gt;allow('add');
          }
          public function add(){
                  if($this-&gt;request-&gt;is('post')){
                          $this-&gt;User-&gt;create();
                          if($this-&gt;User-&gt;save($this-&gt;request-&gt;data)){
                                  $this-&gt;Session-&gt;setFlash(__('The user has been saved'));
                                  return $this-&gt;redirect(array('action' =&gt; 'index'));
                          }
                          $this-&gt;Session-&gt;setFlash(__('The user could not be saved. Please, try again.'));
                  }
          }
          public function login(){
                  $this-&gt;layout = 'mlayout';
                  if($this-&gt;request-&gt;is('post')){
                          debug($this-&gt;Auth-&gt;login());
                          var_dump($this-&gt;request-&gt;data);
                          if($this-&gt;Auth-&gt;login()){
                                  $this-&gt;Session-&gt;setFlash('Logged In');
                                  //return $this-&gt;redirect($this-&gt;Auth-&gt;redirectUrl());
                          }else{
                                  $this-&gt;Session-&gt;setFlash(__('Usuario o Contraseña invalido, intentelo de nuevo.'));
                          }
                  }
          }
          public function logout(){
                  return $this-&gt;redirect($this-&gt;Auth-&gt;logout());
          }
  }
  </code></pre>
  
  <p>AppController code:</p>
  
  <pre><code>class AppController extends Controller{
  
          public $components = array('Session',
                  'Auth' =&gt; array(
                          'loginRedirect' =&gt; array(
                                  'controller' =&gt; 'homes',
                                  'action' =&gt; 'index'
                          ),
                          'logoutRedirect' =&gt; array(
                                  'controller' =&gt; 'homes',
                                  'action' =&gt; 'index'
                          ),
                          'authorize' =&gt; 'controller'
                  )
          );
  
          public function beforeFilter(){
                  $this-&gt;Auth-&gt;allow('index','view','login');
          }
  }
  </code></pre>
  
  <p>Login.ctp</p>
  
  <pre><code>&lt;table id="formtable"&gt;
      &lt;form id="UserForm" method="post" action="/mercadito/users/login"&gt;
          &lt;tr&gt;
          &lt;td align="right"&gt;Login -&gt; &lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="username" style="width: 150px; height: 30px;"/&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
          &lt;td align="right"&gt;Contraseña -&gt; &lt;/td&gt;
          &lt;td&gt;&lt;input type="password" name="password" style="width: 150px; height: 30px;"/&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td align="center"&gt;&lt;input type="submit" value="ENTRAR" style="width: 100px; height: 30px;"/&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/form&gt;
  &lt;/table&gt;
  </code></pre>
  
  <hr>
  
  <pre><code>debug($this-&gt;Auth-&gt;login()) returns: /app/Controller/UsersController.php (line 23) false
  
  var_dump() returns: array(2) { ["username"]=&gt; string(9) "admin" ["password"]=&gt; string(9) "admin" }
  </code></pre>
  
  <p>This happens every time. I changed the location of <code>allow-&gt;('login')</code>, then I checked if my password was well hashed, and it was. But the problem persists.</p>