Closed gimox closed 10 years ago
How do you assign the role? How do you check the access?
i follow the guide for default role.my user has all author children but not reader children. i use Yii::$app->user->can('readPost')
i get false for user author
What are the rules associated with the roles?
this is my console auth file
https://gist.github.com/gimox/11042750
this is the rule https://gist.github.com/gimox/11042924
i create auth from console. it correct create rba.php file in my config i declared default roles in my User model i have field role. i correct assign the role stored in my role field
if i check with user role agencyManager viewAgenziaOwn it return true if i check manageOperators it return false;
@qiangxue if i not use default rules it load permission of child roles
Please read my comment here for the reason: https://github.com/yiisoft/yii2/issues/3151#issuecomment-40806444
First your execute()
should return a boolean.
Second because your two roles have parent-child relationship, if the child rule fails during checkAccess()
, the parent will be marked as failure too.
You should modify your rule definition to not fail the parent.
ok thanks... the bad one is that i undestrand the concepts and it can not be used for complex rules. or for rules that are different to very simple... so for me this design is meaningless. i regret yii2 alpha...
That's how RBAC works. If yii2 alpha works for you, it means it has some issues. In summary, the rules for default roles have to respect hierarchy of the default roles as well.
Please refer to the new doc: https://github.com/yiisoft/yii2/commit/e04dca4daea7c2ba86396332d6e426454dfbfe03
code:
i can not read reader premission from authors, no error simply return always false;