Blogger Information
Blog 91
fans 2
comment 4
visits 127830
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
tp5 钩子验证权限
夏日的烈风的博客
Original
2183 people have browsed it



behavior('app\\admin\\behavior\\CheckAuth'); //验证登录

behavior('app\\admin\\behavior\\RbacAuth');  //权限


class CheckAuth extends Controller
{

   public function run()
   {
       if(Auth::guard()->guest()){
           return $this->redirect('admin\login\index');
       }

   }

}



   public function run()
   {
       if(Request::isAjax() || !Request::controller()){
           $permission_name = trim(substr(Request::path(),strpos(Request::path(),'/')), '/');
       }else{
           $permission_name = strtolower(Request::controller()) . '/' . Request::action(true);
       }

       $user = Auth::guard()->user();

       if($user->can($permission_name) === false){
           dump('你的权限不足,无法访问该页面!'.$permission_name);
           exit;
       }

   }

}

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post