当我尝试实现自定义登录组件时,x 给我一个错误“找不到身份验证适配器“xmlRpc””。
在我的 AppController.php 我有以下
<?php
App::uses('Controller', 'Controller');
//Custom Auth
App::uses('xmlRpc', 'Controller/Component/Auth');
class AppController extends Controller {
//Authentication component
public $components = array(
'Session',
'DebugKit.Toolbar',
'Auth' => array(
'authenticate' => array(
'xmlRpc'
)
)
);
}
然后我的登录组件位于 /Controller/Component/Auth/xmlRpc.php
<?php
App::uses('BaseAuthenticate', 'Controller/Component/Auth');
class xmlRpc extends BaseAuthenticate {
public function authenticate(CakeRequest $request, CakeResponse $response) {
return true;
}
}
?>
在我的用户控制器中,我有以下内容:
<?php
App::uses('AppController', 'Controller');
//Custom Auth
App::uses('xmlRpc', 'Controller/Component/Auth');
class UsersController extends AppController {
public function logout() {
return $this->redirect($this->Auth->logout());
}
public function login() {
if ($this->request->is('post')) {
if ($this->Auth->login()) {
return $this->redirect($this->Auth->redirectUrl());
// Prior to 2.3 use `return $this->redirect($this->Auth->redirect());`
} else {
$this->Session->setFlash(__('Username or password is incorrect'), 'default', array(), 'auth');
}
}
}
}
?>
顺便说一句,在我的身份验证函数中,我总是返回 true 来进行测试。一旦我摆脱了这个错误,就会添加逻辑。请协助并放轻松,因为我是Cake n00b。如何获得蛋糕以查看我的自定义身份验证适配器?