herun1988
(Herun1988)
July 16, 2011, 5:38am
1
Hi,
I encountered a weird problem. For some actions, I set their access rights to any user (*) in the controller. Why does it still redirect me to the log in page? Anyone helps on this? Thanks!!
For example,
array(
'actions' => array('displayattachment1'),
'users' => array('*'),
),
public function actionDisplayAttachment1($id) {
$model = $this->loadModel($id);
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Transfer-Encoding: binary');
header('Content-length: ' . $model->attachment1_filesize);
header('Content-Type: ' . $model->attachment1_filetype);
header('Content-Disposition: attachment; filename="' . $model->attachment1_filename.'"');
echo $model->attachment1;
}
bettor
(Live Webscore)
July 16, 2011, 7:23am
2
hi,
I suspect you’ve incorrectly setup your accessRules. Can you please try to setup your access control like this:
public function filters()
{
return array(
'accessControl', // perform access control for CRUD operations
);
}
public function accessRules()
{
return array(
array(
'actions' => array('displayattachment1'),
'users' => array('*'),
),
);
}
this should resolve your issue
bettor
herun1988
(Herun1988)
July 16, 2011, 8:16am
3
My accessRules setup is correct. I have no idea how this comes about.
bettor:
hi,
I suspect you’ve incorrectly setup your accessRules. Can you please try to setup your access control like this:
public function filters()
{
return array(
'accessControl', // perform access control for CRUD operations
);
}
public function accessRules()
{
return array(
array(
'actions' => array('displayattachment1'),
'users' => array('*'),
),
);
}
this should resolve your issue
bettor
softark
(Softark)
July 16, 2011, 8:33am
4
Maybe this …
array(
- 'actions' => array('displayattachment1'),
+ 'actions' => array('displayAttachment1'),
'users' => array('*'),
),
mdomba
(Maurizio Domba Cerin)
July 16, 2011, 11:04am
6
can you post all your rules… maybe some rule before this one is preventing it…
herun1988
(Herun1988)
July 17, 2011, 2:20am
7
I know what the problem is… I forgot to write ‘allow’…
array('allow',
'actions' => array('displayattachment1'),
'users' => array('*'),
),