Difference between #114 and #115 of
Yii v2 snippet guide

Revision #115 has been created by rackycz on Sep 27, 2019, 7:40:47 AM with the memo:

edit
« previous (#114) next (#116) »

Changes

Title unchanged

Yii v2 snippet guide

Category unchanged

Tutorials

Yii version unchanged

2.0

Tags unchanged

tutorial,beginner,yii2

Content changed

[...]
```

As you can see in the snippet above, other controllers must contain row "use app\controllers\BaseController" + "extends BaseController"


**
ASimple access rights**
---
Every controller can allow different users/guests to use different actions. Method behaviors() can be used to do this. If you generate the controller using GII the method will be present and you will just add the "access-part" like this:
[...]
'roles' => ['@'], // logged in users
// 'roles' => ['?'], // guests
 // 'matchCallback' => function ($rule, $action) { // all logged in users are redirected to some other page // just for demonstration of matchCallback  // return $this->redirect('index.php?r=user/create');  // }
],
],
[...]
```

.. This is all I needed so far. I will add more complex snippet as soon as I need it ...
 
 
Details can be found here [https://www.yiiframework.com/doc/guide/2.0/en/security-authorization](https://www.yiiframework.com/doc/guide/2.0/en/security-authorization).

**Nice URLs**
---
... text ...
[...]
7 0
4 followers
Viewed: 274 972 times
Version: 2.0
Category: Tutorials
Written by: rackycz
Last updated by: rackycz
Created on: Sep 19, 2019
Last updated: a year ago
Update Article

Revisions

View all history