0
votes

I am trying to make my own custom password hasher. I have read CakePHP 2.4 documentation and I have followed instructions

http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#creating-custom-password-hasher-classes

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: 5

Notice: 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

1

1 Answers

3
votes

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');