Reputation: 17
It is not working. I want to index method deny for particular role and redirect on other page.
public function beforeFilter(Event $event)
{
parent::beforeFilter($event);
$this->Auth->deny(['index']); // it's not working
}
Upvotes: 1
Views: 390
Reputation: 2252
you should do the tutorial:
http://book.cakephp.org/3.0/en/tutorials-and-examples/blog-auth-example/auth.html
and then you will stumble on something like this in your controller:
public function isAuthorized($user)
{
// deny index action for certain role
if ($this->request->action === 'index' && $user['role'] === 'particular_role') {
return false;
}
return parent::isAuthorized($user);
}
and this in your appController:
public function isAuthorized($user)
{
// Everyone can access everything
return true;
}
Upvotes: 1