Bahdeng
Bahdeng

Reputation: 434

Yii - Allow access to every actions in all controllers to authenticated user

I have many actions in my project and I don't want to write all the action names in the access rules. I am writing my access rule in Controller inside components. Is there any way in Yii that will allow me to give access to all actions once a user is authenticated? Something like a wildcard for actions?

for example

public function accessRules()
     {
        return array(
            array(
                   'allow',
                   'actions'=>array('login'),
                   'users'=>array('*'),
               ),
           array(
                   'allow',
                   'actions'=>array('changepassword','logout',
                        'searchstudent','searchstudentlist','registration','editstudent','undodelete',
                        'edit','leftschool','removestudent','deletestudent','undodeletestudent','undoleftstudent'),
                   'users'=>array('@'),
               ),
              array('deny'),
            );     
      }

There are many more actions and i don't want to write each and every one of them

Thanks in advance

Upvotes: 2

Views: 2693

Answers (1)

Justinas
Justinas

Reputation: 43481

Just omit actions part from rules as stated here

Upvotes: 4

Related Questions