My AppController
-
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
.找不到原因。可能有什么问题?
数组中有拼写错误。您的身份验证密钥应如下所示:
'authenticate' => array(
'Form' => array(
'fields' => array('username' => 'email'),
'passwordHasher' => 'Blowfish'
),
),
authenticate
数组密钥采用一系列身份验证机制。您得到的错误是因为 CakePHP 认为有一个名为 passwordHasher
的身份验证系统。