title: Yii2 - RBAC Control Not working
body: <p>I am trying to develop a yii2 app where members have two roles: admin and member. So, I was following the default role method as described in <a href="http://www.yiiframework.com/doc-2.0/guide-security-authorization.html" rel="nofollow noreferrer">yii2 documentation</a>.I have a table called 'member' in db which I'm using for login instead of the User.php model. </p>
  
  <p>My web.php config file</p>
  
  <pre><code> 'authManager' =&gt; [
          'class' =&gt; 'yii\rbac\PhpManager',
          'defaultRoles' =&gt; ['admin', 'member'],
      ],
   'user' =&gt; [
              'identityClass' =&gt; 'app\models\Member',
              'enableAutoLogin' =&gt; true,
     ],
  </code></pre>
  
  <p>I created rbac folder in app directory and added UserGroupRule.php as shown below:</p>
  
  <pre><code>use Yii;
  use yii\rbac\Rule;
  
  /**
   * Checks if user group matches
   */
  class UserGroupRule extends Rule
  {
      public $name = '';
  
      public function execute($user, $item, $params)
      {
          if (!Yii::$app-&gt;user-&gt;isGuest) {
              $group = Yii::$app-&gt;user-&gt;identity-&gt;role;
              if ($item-&gt;name === 'admin') {
                  return $group == 1;
              } elseif ($item-&gt;name === 'member') {
                  return $group == 1 || $group == 2;
              }
          }
          return false;
      }
  }
  
  $auth = Yii::$app-&gt;authManager;
  
  $rule = new \app\rbac\UserGroupRule;
  $auth-&gt;add($rule);
  
  $member = $auth-&gt;createRole('member');
  $member-&gt;ruleName = $rule-&gt;name;
  $auth-&gt;add($member);
  // ... add permissions as children of $author ...
  
  $admin = $auth-&gt;createRole('admin');
  $admin-&gt;ruleName = $rule-&gt;name;
  $auth-&gt;add($admin);
  $auth-&gt;addChild($admin, $member);
  </code></pre>
  
  <p>As a part of testing, added this bit of code in one of the controllers:</p>
  
  <pre><code>'access' =&gt; [
       'class' =&gt; AccessControl::className(),
        'only' =&gt; ['index', 'view', 'create', 'update', 'delete'],
        'rules' =&gt; [
              [
                  //'actions' =&gt; ['admin'],
                  'allow' =&gt; true,
                  'roles' =&gt; ['admin'],
              ],
          ], 
   ],
  </code></pre>
  
  <p>Problem is, it gives me Forbidden (#403) error even when I try to access one of the actions(i.e. index) as an admin. So, whats am I missing? Please help!</p>
  
  <p>P.S. As mentioned, I'm using db for login. If you want, take a look at <a href="https://stackoverflow.com/questions/32011068/yii2-login-with-database">member.php</a> model. </p>