I am trying to make my own custom password hasher. I have read CakePHP 2.4 documentation and I have followed instructions
This is my CustomPasswordHasher Class on Controller/Component/Auth
App::uses('CustomPasswordHasher', 'Controller/Component/Auth');
class CustomPasswordHasher extends AbstractPasswordHasher {
public function hash($password) {
return $password;
}
public function check($password, $hashedPassword) {
return $password === $this->hash($hashedPassword);
}
}
These are my components on UsersController
public $components = array(
'Session',
'Auth' => array(
'loginRedirect' => array('controller' => 'posts', 'action' => 'index'),
'logoutRedirect' => array('controller' => 'pages', 'action' => 'display', 'home'),
'authenticate' => array(
'Form' => array(
'passwordHasher' => array(
'className' => 'Custom'
)
)
)
)
);
When im trying to log in a user i got this error:
Error: Class 'AbstractPasswordHasher' not found
File: C:\\Users\\Jonathan\\Dropbox\\Public\\WebSites\\umbrellaApp\\app\\Controller\\Component\\Auth\\CustomPasswordHasher.php
Line: 5Notice: If you want to customize this error message, create app\\View\\Errors\\fatal_error.ctp
i've looked up at my core and i can see AbstracrPasswordHasher
can anyone help me?
Thanks
Looks like there's a mistake in the documentation, of course it should load AbstractPasswordHasher
, not CustomPasswordHasher
, which is the name of the class being created.
Your App::uses()
call should look like this:
App::uses('AbstractPasswordHasher', 'Controller/Component/Auth');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.