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;
}
}
}