The code in the controller is publicfunctionbeforeAction ($ action) {code ...}} the prompt "no operation permission" is displayed on the page. the corresponding $ contro... is added to the database... rbac permission can be verified normally, but an exception is thrown during Controller authentication.
The code in the controller is like this.
Public function beforeAction ($ action ){
$ Controller = Yii ::$ app-> controller-> id; // Obtain the controller $ action = Yii ::$ app-> controller-> action-> id; // Obtain the method if (Yii: $ app-> user-> can ($ controller. '_'. $ action) {return true;} else {throw new \ yii \ web \ UnauthorizedHttpException ('you do not have operation authorization ');}
}
The prompt "no operation permission" is displayed on the page. the corresponding $ controller is added to the database. '_'. $ action data ...........
Reply content:
Rbac permission can be verified normally, but an exception is thrown during Controller authentication.
The code in the controller is like this.
Public function beforeAction ($ action ){
$ Controller = Yii ::$ app-> controller-> id; // Obtain the controller $ action = Yii ::$ app-> controller-> action-> id; // Obtain the method if (Yii: $ app-> user-> can ($ controller. '_'. $ action) {return true;} else {throw new \ yii \ web \ UnauthorizedHttpException ('you do not have operation authorization ');}
}
The prompt "no operation permission" is displayed on the page. the corresponding $ controller is added to the database. '_'. $ action data ...........
Write real addresses in the data, for example:
'/'. $ Controller. '/'. $ action
Output$controller.'_'.$actionThis variable is used by myself under the parent class,
Yii: $ app-> controller-> id and Yii: $ app-> controller-> action-> id are null.