Commit 9d792483 authored by zfc's avatar zfc Committed by hujun

后台权限控制

parent 137cb709
...@@ -63,6 +63,8 @@ class Basic extends Controller ...@@ -63,6 +63,8 @@ class Basic extends Controller
$this->userVerify(); $this->userVerify();
} }
$this->userAuth($requestPath);
$this->userAuth($requestPath); $this->userAuth($requestPath);
} }
...@@ -83,12 +85,34 @@ class Basic extends Controller ...@@ -83,12 +85,34 @@ class Basic extends Controller
foreach ($session as $v){ foreach ($session as $v){
} }
public function userAuth(){ /**
$request= \think\Request::instance(); * 权限判定
$r= $request->controller(); * @param $requestPath
$route= $request->module(); * @return Response
$name= $request->action(); */
$url=$route."/".$name; public function userAuth($requestPath){
$session= Session::get("userinfo.nav");
$r=0;
//判断当前控制器用户是否拥有进入权限
foreach ($session as $v){
//不区分大小写
if(strcasecmp(trim($v['name']),$requestPath)==0){
$r=$v;
}
}
if($r=='0'){
if($this->request->isAjax()){
return $this->response('300','没有权限');
}else{
// $this->error('没有当前页面权限');
}
}else{
Session::set("userRule",$r);
}
//print_r($r);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment