当前后台的一些模块开发完成之后,我需要实现后台的一些权限访问控制,很开心的是,在yii framework里面,很好的提供了这个功能,具体实现的方法是:
/*
* 在当前控制器实现用户访问的控制
*/
function filters() {
return array(
'accessControl',
);
}
/*
* show add update del 等方法在进行访问的时候需要用户登录系统
* 为具体方法被访问设置条件
*/
public function accessRules() {
return array(
//show 必须是登录系统的用户来访问
array(
'allow',
'actions'=>array('add', 'del', 'update', 'list', 'show', 'subtype'),
'users'=>array('@'),
),
array(
'deny',
'users'=>array('*'),
),
);
}
权限访问设置好之后,便可以测试网站,可以部署到服务器上面了。
文章的脚注信息由WordPress的wp-posturl插件自动生成
微信扫一扫,打赏作者吧~![[整理][转载]win下网卡抓包发包库Npcap使用](http://www.jyguagua.com/wp-content/themes/begin/timthumb.php?src=http://www.jyguagua.com/wp-content/uploads/2023/08/demo_1-1024x711.jpg&w=280&h=210&zc=1)
![[转载]基础数据char,int,double,string是线程安全的吗?](http://www.jyguagua.com/wp-content/themes/begin/img/random/17.jpg)
![[整理]how to run flask with pyqt5](http://www.jyguagua.com/wp-content/themes/begin/timthumb.php?src=http://www.jyguagua.com/wp-content/uploads/2021/03/pyqt_flask.png&w=280&h=210&zc=1)
![[已解决]LINK : fatal error LNK1158: cannot run 'rc.exe' 错误的解决办法](http://www.jyguagua.com/wp-content/themes/begin/timthumb.php?src=http://www.jyguagua.com/wp-content/uploads/2021/02/Snipaste_2021-02-17_15-18-26-1024x505.png&w=280&h=210&zc=1)