Yii Framework Forum: Allow guest access to module controller/action - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Allow guest access to module controller/action Rate Topic: -----

#1 User is offline   Paul G. 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 76
  • Joined: 24-April 09
  • Location:Tel Aviv, Israel

Posted 13 February 2018 - 07:50 AM

I have a problem allowing guests access actions in modules, but not in actions in controllers of the application.


In the Control.php file I have added this code to prevent guests any access:

        public function filters() {
            return array('accessControl');
        }

        public function accessRules() {
            return array(
                array('allow',
                    'users'=>array('@'),
                ),
                array('deny')
            );
        }


Now I am adding a module that has controls and actions ment for guests. The controllers get this code, but guests are redirected to the login URL given in "loginUrl" configuration for user component (WebUser class):
        public function filters() {
            return array('accessControl');
        }

        public function accessRules() {
            return array(
                array('allow',
                    'users'=>array('*'),
                )
            );
        }



On the other hand, when I add an application controller with the same access code as the previous example above in the module, guests do get access.

Can anyone explain what is wrong?
Yii fan from Norway
0

#2 User is offline   Paul G. 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 76
  • Joined: 24-April 09
  • Location:Tel Aviv, Israel

Posted 14 February 2018 - 02:35 AM

I had a problem with "throw new CHttpException(...)" which redirected the application to site/error which required a user to log in. Problem solved! :)
Yii fan from Norway
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users