我尝试添加菜单 map
在后端。我用 yii2-advanced
.这是我的“ Controller ”代码:
public function actionMap()
{
return $this->render('map');
}
但是,当我尝试使用此网址访问它时
http://localhost/yii2advanced/backend/web/index.php?r=site/map
, 我收到错误消息 Forbidden (#403) - You are not allowed to perform this action
.我不明白为什么会收到此错误消息,有人可以帮我解决此问题吗?
最佳答案
这是由 AccessControl 引起的.最有可能的 Action map
根据访问规则被阻止。允许所有经过身份验证的用户使用它的示例:
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'access' => [
'class' => \yii\filters\AccessControl::className(),
'only' => ['create', 'update'],
'rules' => [
// allow authenticated users
[
'allow' => true,
'roles' => ['@'],
],
// everything else is denied
],
],
];
}
或者,您可以根据某些 RBAC 角色调整访问权限。
关于yii2 - Forbidden (#403) - 你不能执行这个 Action [Yii2],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32448409/