doudi8829 2016-04-08 13:41
浏览 67

无法获得用户权限yii2

I'm triying to make certain menu items visible for users that have specific permissions but so far i have failed, what im doing is this:

    function(){                                                
                if(Yii::$app->user->can('abrir caja'))
                {
                  return true;                                                    
                }
                  else
                  {
                   return false;
                  }                                                
     }

But im failing to get the user permissions is what i'm thinking, my question is how can i get the current user permissions? I have already checked that my users have their respective roles and permissions assigned.

  • 写回答

2条回答 默认 最新

  • drq231358 2016-04-08 14:01
    关注

    You can use the getPermissionsByUser() method. Example:

    $userId = Yii::$app->user->getId();
    var_dump(Yii::$app->authManager->getPermissionsByUser($userId));
    
    评论

报告相同问题?