襄陽網(wǎng)站建設(shè)分享:thinkphp6 Auth權(quán)限管控
Auth安裝地址
//thinkphp5.1 composer require liliuwei/thinkphp-auth=1.0.*
//thinkphp6.0 composer require liliuwei/thinkphp-auth=2.0.*
1.調(diào)用
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判斷控制器是否有權(quán)限
if (session('id')!=1 && $name!="/admin/Index/index" && $name!="/admin/Index/welcome" && $name!="admin/Admin/logout"){ if (!$auth->check($name,session('id'))){ echo ""; } }
[聲明]原創(chuàng)不易,請轉(zhuǎn)發(fā)者備注下文章來源(hbsjsd.cn)【速建時代】。