Yii2 MVC 基础授权
Yii2 MVC base Authorization
我的 yii2 项目有问题。我使用了 RBAC 授权,它工作正常。
在下面的代码中,'@'
表示登录的用户。它位于 SiteController
-不使用 RBAC。
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'actions' => ['login', 'error', 'confirm', 'changepassword', 'thongbao', 'request-password-reset', 'reset-password', 'distance',
'nhatram', 'updatediaban', 'leas', 'thongkell', 'thongkells', 'nodetb', 'xemnode', 'bcthang','mailcb'
],
'allow' => true,
],
[
'actions' => ['logout', 'index', 'leaslineall', 'up'],
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'logout' => ['post'],
],
],
];
}
所以我只想为名为 "Superadmin"
的特定用户授权某些操作
我该怎么办?谢谢!
你试过这个参考吗?
关于你的RBAC授权很详细
https://www.yiiframework.com/wiki/771/rbac-super-simple-with-admin-and-user
我的 yii2 项目有问题。我使用了 RBAC 授权,它工作正常。
在下面的代码中,'@'
表示登录的用户。它位于 SiteController
-不使用 RBAC。
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'actions' => ['login', 'error', 'confirm', 'changepassword', 'thongbao', 'request-password-reset', 'reset-password', 'distance',
'nhatram', 'updatediaban', 'leas', 'thongkell', 'thongkells', 'nodetb', 'xemnode', 'bcthang','mailcb'
],
'allow' => true,
],
[
'actions' => ['logout', 'index', 'leaslineall', 'up'],
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'logout' => ['post'],
],
],
];
}
所以我只想为名为 "Superadmin"
我该怎么办?谢谢!
你试过这个参考吗?
关于你的RBAC授权很详细
https://www.yiiframework.com/wiki/771/rbac-super-simple-with-admin-and-user