CakePHP v.2.4 ...
I am following this documentation trying to configure the Auth component to use my custom password hash class:
App::uses('PHPassPasswordHasher', 'Controller/Component/Auth');
class AppController extends Controller {
public $components = array(
'Session',
'Cookie',
'Auth' => array(
'authenticate' => array(
'Form' => array(
'fields' => array('username'=>'email', 'password'=>'password'),
'passwordHasher' => 'PHPass'
)
),
Inside my UserController :: login (), I debug the return from $this->Auth->login();and always returns false, even when I send the correct email address / password.
(NOTE: It seems strange to me that it login()does not accept any parameters, but the documents seem to imply that it automatically looks into the request data. And this makes sense if my configurations do not correctly call it to check the User.email field instead of the username .)
:
array(
'User' => array(
'password' => '*****',
'email' => 'whatever@example.com'
)
)
?
Update2
, . , , .
app/Controller/Component/Auth/PHPassPasswordHasher.php
<?php
App::import('Vendor', 'PHPass/class-phpass');
class PHPassPasswordHasher extends AbstractPasswordHasher {
public function hash($password) {
$hasher = new new PasswordHash( 8, true );
return $hasher->HashPassword($password);
}
public function check($password, $hashedPassword) {
debug('PHPassHasher'); die('Using custom hasher');
$hasher = new new PasswordHash( 8, true );
return $hasher->CheckPassword($password, $hashedPassword);
}
}
AHA! debug() ... , .
Update3
: , (Ex: "Simple", "Blowfish" ) . , , , , .
Update4
$this->settings /lib/Cake/Controller/Component/Auth/BaseAuthenticate.php, :
array(
'fields' => array(
'password' => 'password',
'username' => 'email'
),
'userModel' => 'User',
'scope' => array(),
'recursive' => (int) 0,
'contain' => null,
'passwordHasher' => 'PHPass'
)