我在CakePHP的擴展BaseAuthorise並創建了一個名爲LdapAuthenticate新的類,這個位於我的/應用/控制器/組件/認證/ LdapAuthenticate內,它目前看起來像這樣CakePHP的身份驗證與LDAP
<?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與身份驗證功能,可以依靠,如果返回錯誤的對象用戶是否登錄。
有人可以提出爲什麼會產生這個錯誤嗎?
你已經混了[授權](http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#creating-custom-authorize-objects)和[認證(http://book.cakephp.org/2.0/en/core-libraries/components/authentication。 HTML#創建定製驗證的對象)。 – ndm
兩者都沒有彼此的工作。 –