I'm using Cakemanager Authorizer, but remarked that Authorizer
is not running the isAuthorized()
method. My config is as follow :
$this->loadComponent('Auth', [
'authenticate' => [
'Form' => [
'fields' => ['username' => 'email', 'password' => 'password']
],
'ADmad/HybridAuth.HybridAuth'
],
'loginRedirect' => [
'plugin' => FALSE,
'controller' => 'Pages',
'action' => 'display',
'home'
],
'logoutRedirect' => [
'controller' => 'Pages',
'action' => 'display',
'home'
],
'authorize' => 'Controller'
]);
$this->loadComponent('Utils.Authorizer');
And the isAuthorized
method in PagesController
:
public function isAuthorized($user)
{
$this->Authorizer->action(['display', 'contact', 'about', 'tips', 'terms'], function($auth) {
$auth->allowRole(['*']);
});
return $this->Authorizer->authorize();
}
But when accessing any of the listed actions, I got redirected to login page. I try this \Cake\Log\Log::info($this->Authorizer);
and got the following log output :
Utils\Controller\Component\AuthorizerComponent Object ( [components] => Array ( ) [implementedEvents] => Array ( [Controller.initialize] => beforeFilter ) [_config] => Array ( [roleField] => role_id [Authorizer] => Array ( [roleField] => role_id ) ) )
And I think the Authorizer Component is running beforeFilter
instead of isAuthorized
. Am I doing something wrong ?