Weird: Anonymous users can't access some views which are opened to any user(*)

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;

    }

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

My accessRules setup is correct. I have no idea how this comes about.

Maybe this …


 array(

-                'actions' => array('displayattachment1'),

+                'actions' => array('displayAttachment1'),

                'users' => array('*'),

            ),

still cannot…

can you post all your rules… maybe some rule before this one is preventing it…

I know what the problem is… I forgot to write ‘allow’…


array('allow',

                'actions' => array('displayattachment1'),

                'users' => array('*'),

            ),