L
L
Leopandro2016-04-27 12:42:57
Yii
Leopandro, 2016-04-27 12:42:57

How to set accessrule by field in database?

How to set access to actions by a field in a record, for example, a user has $user->role = 1, then give access, if $user->role = 4, then no.
did like this:

'access' => [
                'class' => AccessControl::className(),
                'ruleConfig' => [
                    'class' => AccessRule::className(),
                ],
                'rules' => [
                    [
                        'allow' => true,
                        'roles' => [1,4,5],
                    ],
                ],
            ],
- does not work

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Donkovtsev, 2016-04-27
@Demetriy

RBAC
The roles field is not the user's role attribute, but the rights associated with the user .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question