Answer the question
In order to leave comments, you need to log in
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) )
Array
(
[0] => Сlient
)
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question