襄阳做网站,襄阳网站设计,襄阳网站开发,微信小程序开发,网站设计制作,专业建站公司

当前位置:

襄阳网站建设分享:thinkphp6 Auth权限管控

常见问题

1946

文章来源(hbsjsd.cn)湖北高端网站定制开发公司-速建时代

Auth安装地址

//thinkphp5.1
composer require liliuwei/thinkphp-auth=1.0.*
//thinkphp6.0
composer require liliuwei/thinkphp-auth=2.0.*

1.调用

use liliuwei\think\Auth;

2.获取控制器

$request=\think\facade\Request::instance();
 $root=$this->request->root();
 $con=$this->request->controller();
 $action = $this->request->action();
 $name=$root.'/'.$con.'/'.$action;

3.实例化 Auth

 $auth=new Auth();

4.使用Auth判断控制器是否有权限

if (session('id')!=1 && $name!="/admin/Index/index" && $name!="/admin/Index/welcome" && $name!="admin/Admin/logout"){  
  if (!$auth->check($name,session('id'))){  
        echo "";    
   }
}


[声明]原创不易,请转发者备注下文章来源(hbsjsd.cn)【速建时代】。

速建时代高端网站定制开发回到顶部
站内SEO关键词搜索