I'm using cakePHP's isAuthorized() function to check if a user is authorized to execute a controller action, but the weird problem I'm having is that the permissions on my other controller actions are blocked from the user as well. I'm only doing this:
function isAuthorized()
{
$user_id_logged_in = $this->Auth->user('id');
switch($this->action)
{
case: 'my_action':
if($user_id_logged_in)
{
// check if user has access to execute controller action
return $this->Acl->check(array(
'model' => 'MyModel', 'foreign_key' => $my_foreign_key),
'controllers/MyController/'.$this->action);
}
else
{
return false;
}
break;
}
}
I want to check if the logged user is authorized to execute the action my_action. But when I do this, the user loses permissions for the other actions in my controller as well. Any idea what is wrong with this?
Thank you
$user_id_logged_in? - David Gallagher$this->Auth->user('id');- user765368check()method takes 3 string parameters.check($aro, $aco, $action = "*"). You can see that here. - David GallagherMyModelshould be the name of your users model (Userprobably) and$my_foreign_keyshould be$user_id_logged_in- David Gallagher