I have extended BaseAuthorise in CakePHP and created a new class named LdapAuthenticate, this is located within my /app/Controller/Component/Auth/LdapAuthenticate and it currently looks like this
<?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...";
}
}
Within my AppControl I have
public $components = array(
'Session',
'Auth' => array(
'loginRedirect' => array('controller' => 'posts', 'action' => 'index'),
'logoutRedirect' => array('controller' => 'pages', 'action' => 'display', 'home'),
'authenticate' => array('Ldap')
)
);
And then within my login method I have
public function login() {
if ($this->request->is('post')) {
$this->Auth->authorize();
}
}
However I am getting the error
Error: Class LdapAuthenticate contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (BaseAuthorize::authorize)
However in the CakePHP documentation and cookbook it instructs me to set it up the way I have LdapAuthetnticate extends BaseAuthorise with a function for authenticate which can return an object of false depending on if the user logged in or not.
Can anybody suggest why this error is being produced?
您已经扩展了抽象类-因此您必须提供自己的抽象方法实现-在这种情况下,您必须实现:
authorize ( array $user , CakeRequest $request )
as ndm says you are extending BaseAuthorize
but what you want is BaseAuthenticate
class LdapAuthenticate extends BaseAuthenticate
{
public function authenticate(CakeRequest $request, CakeResponse $response)
{
// ....
return $userData;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.