I am trying to create a custom passwordHaser. I have create files like below.
EncryptPasswordPasswordHasher.php
App::uses('AbstractPasswordHasher', 'Controller/Component/Auth');
class EncryptPasswordPasswordHasher extends AbstractPasswordHasher
{
public function hash($password, $method = 'md5', $crop = true, $start = 4, $end = 10)
{
...
}
public function check($password, $hashedPassword = null)
{
...
}
}
AdminController.php (configure component)
App::uses('EncryptPasswordPasswordHasher ', 'Controller/Component/Auth');
public $components = [
'Auth' => [
'authenticate' => [
'Form' => [
'userModel' => 'Admin',
'fields' => [
'username' => 'username',
'password' => 'password'
],
'passwordHasher' => [
'className' => 'EncryptPassword'
]
]
],
'loginAction' => [
'controller' => '',
'action' => 'login'
],
'logoutRedirect' => [
'controller' => '',
'action' => 'login'
],
'loginRedirect' => [
'controller' => '',
'action' => 'dashboard'
]
]
];
Admin.php (AdminModel)
App::uses('EncryptPasswordPasswordHasher ', 'Controller/Component/Auth');
public function beforeSave($options = array()) {
if (!empty($this->data[$this->alias]['password'])) {
$passwordHasher = new EncryptPasswordPasswordHasher();
$this->data[$this->alias]['password'] = $passwordHasher->hash(
$this->data[$this->alias]['password']
);
}
return true;
}
I want to use my own password encryption for this I have create this EncryptPasswordPasswordHasher in app/Controller/Component/Auth folder. but this is not works perfect. It give below fatal error.
Error: Class 'EncryptPasswordPasswordHasher' not found
I have already search in google for this issue, but i don't find any proper solution. No articles is there who have a proper instruction to use the our custom PasswordHaser.
Please help me in this concern. Thanks.