2014-12-05 35 views
-1

AppController -得到錯誤使用CakePHP 2.5.6密碼散列器

App::uses('Controller', 'Controller'); 

/** 
* Application Controller 
* 
* Add your application-wide methods in the class below, your controllers 
* will inherit them. 
* 
* @package  app.Controller 
* @link  http://book.cakephp.org/2.0/en/controllers.html#the-app-controller 
*/ 
class AppController extends Controller 
{ 

    // Pass settings in $components array 
    public $components = array(
          'Auth' => array(
            'loginAction' => array(
                 'controller' => 'users', 
                 'action'  => 'login', 
            ), 
            'authError' => 'You are not permitted for this action.', 
            'authenticate' => array(
                 'Form'   => array(
                      'fields' => array('username' => 'email') 
                      ), 
                 'passwordHasher' => 'Blowfish' 
            ), 
          'Session', 
         ) 
    ); 

而且我User模型。 -

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

/** 
* This is a "Docblock Comment," also known as a "docblock." The class' 
* docblock, below, contains a complete description of how to write these. 
*/ 

class User extends AppModel 
{ 

但是我收到錯誤 - AUTHENTICATION ADAPTER "PASSWORDHASHER" WAS NOT FOUND。 不能找出原因。可能是什麼問題?

回答

1

陣列中存在拼寫錯誤。您的驗證密鑰應該是這樣的:

'authenticate' => array(
     'Form' => array(
      'fields' => array('username' => 'email'), 
      'passwordHasher' => 'Blowfish' 
     ), 
    ), 

authenticate數組密鑰引入一組驗證機制。你得到的錯誤是因爲CakePHP認爲有一個名爲passwordHasher的認證系統。

+0

謝恩曼..問題解決了.. :) – 2014-12-08 06:03:38

+0

沒問題!這是社區在這裏做的。 – 2014-12-08 16:48:59