In my app I have 3 roles of Users (user, admin, non logged user), and I want to redirect them to different pages when access is denied. How to do that?
In time, what $this->Auth->authorize = array('Controller'); means? I didn't understand this in cake docs.
Thanks all.
I would have it in a IF statement, but perhaps someone else can suggest a more CakePHP specific method..
if($user === 'Admin') {
//Admin Redirect
$redirectController = 'admin';
$redirectMethod = 'admin_index';
} elseif ($user === 'User') {
//User Redirect
$redirectController = 'user';
$redirectMethod = 'index';
} else {
//Not logged in
$redirectController = 'SomeController';
$redirectMethod = 'someMethod';
}
$this->Auth->unauthorizedRedirect = array(
'controller' => $redirectController,
'action' => $redirectMethod
);
$this->Auth->authorize = array('Controller');
means that the Authorization is done at the Controller level. I believe you can change where authorization is carried out using this.