L
L
Lander2015-08-26 13:44:45
Yii
Lander, 2015-08-26 13:44:45

How are RBAC roles inherited in Yii2?

Good afternoon.
There was a small plug, which I know how to solve with crutches, but I want some kind of kosher way.
So, there are several roles and rules in auth_item. Among them are the ROLES User and Client .
Accordingly, auth_item_child has an entry: parent = User , child = Client .
And in auth_assignment there is an entry: item_name = Client , user_id = 1 , ...
So, when you try to do

array_keys( Yii::$app->authManager->getRolesByUser(1) )

returns only
Array
(
    [0] => Сlient
)

and it would be desirable that ALL ROLES which are at the user were stretched. What is the best way to do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Khomenko, 2015-08-26
@usdglander

All right. Your User role includes the Client role. You have associated the Client role with user ID:1. In this case, the user with ID:1 has rights to the Client and all its child items (not parent ones), but he does not have such. If you associate a user with the User role, only then will he have rights to User and Client.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question