简体   繁体   中英

cakePHP class blowfishpasswordhasher not found

I am trying to implement blowfish password hasher in my cakePHP app. I've followed along with the tutorial.

When trying to add a new user I'm getting a fatal error when I try to instantiate a new BlowfishPasswordHasher class in the beforeFilter function of my user model. The error states :Class 'BlowfishPasswordHasher' not found.

I saw the question here but it looks like I have everything setup correctly.

Here is relevant code in my app/Controller/appController:

class AppController extends Controller {

public $components = array(
    'Flash',
    'RequestHandler',
    'Auth' => array(
        'authenticate' => array(
            'Form' =>array(
                'passwordHasher' => 'Blowfish'
                'fields' => array(
                    'username' => 'username',
                    'password' => 'password'
                ),

            ),

        ),
        'loginRedirect' => '/trails',
        'logoutRedirect' => '/',
    ),
);

app/Model/User.php

<?php
App::uses('AppModel', 'Model');
App::uses('BlowfishPasswordHasher', 'Conroller/Component/Auth');

class User extends AppModel {

public function beforeSave($options = array()) {
    if (isset($this->data[$this->alias]['password'])) {
        $passwordHasher = new BlowfishPasswordHasher();
        $this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password']
        );
    }
return true;
}

Any help is much appreciated!!!

Looks like you have a spelling mistake:

App::uses('BlowfishPasswordHasher', 'Conroller/Component/Auth');

Change this to:

App::uses('BlowfishPasswordHasher', 'Controller/Component/Auth');

There's no folder called Conroller and therefore, it's unable to locate the BlowFish library file.

Hope this helps.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM