W
W
WildJust2016-07-11 22:47:35
Yii
WildJust, 2016-07-11 22:47:35

Need help with AccessControl in Yii2!?

public function behaviors()
    {
        return [
        
            'access' => [
                'class' => AccessControl::className(),
                'rules' => [
                    'actions' => ['index'],
                    'allow' => true,
                    'roles' => ['@'],
                ],
            ],
           'verbs' => [
                'class' => VerbFilter::className(),
                'actions' => [
                    //'delete' => ['POST'],
                ],
            ],
        ];
    }

I want to make the action index available only to registered users, it throws an error Setting unknown property: yii\filters\AccessRule::0

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Pavlenko, 2016-07-11
@WildJust

'rules' => [
                    [
                        'actions' => ['index'],
                        'allow' => true,
                        'roles' => ['@'],
                    ],
                ],

Inside rule we need another array

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question