How to allow guest access to some actions in Yii2 Controller? -


i'd know how configure controller allow actions executed guest , able show view guest in yii2.

i've tried rule in behaviour

       'access' => [            'class' => accesscontrol::classname(),                                            'rules' => [                     [                                            'actions' => ['create','update'],                                'allow' => true,                         'ips' => ['127.0.0.1'],                                              ]                                        ],                               ] 

edit: config tried :

    'access' => [                 'class' => accesscontrol::classname(),                                           'rules' => [                                                     [                         'allow' => true,                         'actions' => ['create', 'update'],                         'roles' => ['?'],                     ],                 ],                               ] 

edit2: after checking out new project(yii2-advanced) scratch , trying generate controllers , models again previous rules worked, think configuration previous project preventing me access guest somehow.

in rules

                [                     'allow' => true,                     'actions' => ['login', 'signup'],                     'roles' => ['?'],                 ], 

then actions login , signup allowed anonymous users.

or can use only method also, exempt action not require acl.

for more details,see http://www.yiiframework.com/doc-2.0/guide-security-authorization.html


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -