yiisoft / yii2

Yii 2: The Fast, Secure and Professional PHP Framework
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
14.24k stars 6.91k forks source link

[yii\rbac\DbManager] $defaultRoles do not give permissions to users #19867

Closed mikk150 closed 1 year ago

mikk150 commented 1 year ago

What steps will reproduce the problem?

  1. create permission called viewPost
  2. create role called user
  3. assign permission viewPost to role user
  4. make yii\rbac\DbManager with $defaultRoles => ["user"]
  5. ask from manager if current user can view post

What is the expected result?

it will tell no, you shall not view posts

What do you get instead?

since user has permission to view post, it should say yes

Additional info

Q A
Yii version 2.0.41.1
PHP version 7.1.33
Operating system Docker
mikk150 commented 1 year ago

This is problem specifically on DbManager as PhpManager does not have this problem

mikk150 commented 1 year ago

Turns out it was issue on my code... I tried to add test to yii2 framework, and all tests passed.. so it had to be my code