我在 CakePHP 中扩展了 BaseAuthorise 并创建了一个名为 LdapAuthenticate 的新类,它位于我的 /app/Controller/Component/Auth/LdapAuthenticate 中,目前看起来像这样
<?php
App::uses('BaseAuthorize', 'Controller/Component/Auth');
class LdapAuthenticate extends BaseAuthorize {
public function authenticate(CakeRequest $request, CakeResponse $response) {
// Do things for ldap here.
echo "Running...";
}
}
在我的 AppControl 中,我有
public $components = array(
'Session',
'Auth' => array(
'loginRedirect' => array('controller' => 'posts', 'action' => 'index'),
'logoutRedirect' => array('controller' => 'pages', 'action' => 'display', 'home'),
'authenticate' => array('Ldap')
)
);
然后在我的登录方法中,我有
public function login() {
if ($this->request->is('post')) {
$this->Auth->authorize();
}
}
但是我收到了错误
Error: Class LdapAuthenticate contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (BaseAuthorize::authorize)
然而,在 CakePHP 文档和食谱中,它指示我设置它的方式,我让 LdapAuthetnticate 扩展 BaseAuthorise 并使用一个用于身份验证的函数,根据用户是否登录,它可以返回一个 false 对象。
任何人都可以提出为什么会产生这个错误吗?