zoukankan      html  css  js  c++  java
  • thinkphp5_auth 权限认证

    1.Auth类文件引入

    2.写一个公共类AuthInfo,所有要权限认证的类都继承此公共类AuthInfo

    class AuthInfo extends Controller{
      protected function _initialize(){
        if(!session("?intel_uid")){
          echo "<script>alert('没有登陆!');window.location.href = '".url('index/index/index')."';</script>";
        }
        $uid = session('intel_uid');
        if($uid==1){
          return true;
        }
        $userArr=db('in_user')->where('id='.$uid)->find();
        $access_id = $userArr['role'];
        $auth = new Auth();
        $name=request()->module().'/'.request()->controller().'/'.request()->action();
        if(!$auth->check($name,$access_id)){
          $this->error('没有权限!');
        }
      }
    }

  • 相关阅读:
    将.lib库文件转换成.a库文件的工具
    协议
    协议
    bzoj1066
    bzoj2668
    bzoj2245
    bzoj2324后续思考
    bzoj2324
    jsoi2014前两轮回眸
    bzoj1293
  • 原文地址:https://www.cnblogs.com/walksnow/p/6718114.html
Copyright © 2011-2022 走看看