title: How to configure CakePHP's $this->Auth->login() to use custom password hasher
body: <p>CakePHP v.2.4...</p>
  
  <p>I'm following <a href="http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#identifying-users-and-logging-them-in" rel="nofollow">this documentation</a> trying to set up the Auth component to use my custom password hashing class:</p>
  
  <pre><code>App::uses('PHPassPasswordHasher', 'Controller/Component/Auth');
  
  class AppController extends Controller {
  
      // auth needed stuff
      public $components = array(
          'Session',
          'Cookie',
          'Auth'      =&gt; array(
              'authenticate'      =&gt; array(
                  'Form'  =&gt; array(
                      'fields' =&gt; array('username'=&gt;'email', 'password'=&gt;'password'),
                      'passwordHasher'    =&gt; 'PHPass' 
  
                  )
              ),
  </code></pre>
  
  <p>Inside my UsersController::login() I debug the return from <code>$this-&gt;Auth-&gt;login();</code> and it always returns false, even when I submit the correct email / password.</p>
  
  <p>(NOTE: It looks strange to me that the <code>login()</code> takes no parameters, but the docs seem to imply that it looks into the the request data automatically. And this would make sense if my configurations aren't correctly causing it to check the User.email field instead username.) </p>
  
  <p>The post data from the submitted login form looks like this:</p>
  
  <pre><code>array(
      'User' =&gt; array(
          'password' =&gt; '*****',
          'email' =&gt; 'whatever@example.com'
      )
  )
  </code></pre>
  
  <p>What am I missing?</p>
  
  <p><strong>Update2</strong></p>
  
  <p>I'm starting to suspect that the default hashing algorithm is getting used instead of my custom class. I tried to match the examples in the docs but they're quite vague on how to do this. </p>
  
  <p>Here's the contents of <code>app/Controller/Component/Auth/PHPassPasswordHasher.php</code></p>
  
  <pre><code>&lt;?php
  App::import('Vendor', 'PHPass/class-phpass'); //&lt;--this exists and defines PasswordHash class
  class PHPassPasswordHasher extends AbstractPasswordHasher {
  
      public function hash($password) {
          $hasher = new new PasswordHash( 8, true );
          return $hasher-&gt;HashPassword($password);
      }
  
      public function check($password, $hashedPassword) {
          debug('PHPassHasher'); die('Using custom hasher'); //&lt;--THIS NEVER HAPPENS!
          $hasher = new new PasswordHash( 8, true );
          return $hasher-&gt;CheckPassword($password, $hashedPassword);
      }
  
  }
  </code></pre>
  
  <p><strong>AHA!</strong> The <code>debug()</code> never appears... so I'm pretty sure the problem is with my custom hasher configuration(s).</p>
  
  <p><strong>Update3</strong></p>
  
  <p>Additional clue: I experimented by setting various default hashing algorithms (Ex: "Simple", "Blowfish") and creating users. The hashes which show up in the DB are all the <em>same</em> which tells me that my config settings are getting ignored completely. </p>
  
  <p><strong>Update4</strong></p>
  
  <p>I debugged <code>$this-&gt;settings</code> inside the constructor of /lib/Cake/Controller/Component/Auth/BaseAuthenticate.php and my custom hasher settings <em>are</em> in there:</p>
  
  <pre><code>array(
      'fields' =&gt; array(
          'password' =&gt; 'password',
          'username' =&gt; 'email'
      ),
      'userModel' =&gt; 'User',
      'scope' =&gt; array(),
      'recursive' =&gt; (int) 0,
      'contain' =&gt; null,
      'passwordHasher' =&gt; 'PHPass'
  )
  </code></pre>