Commit 4a761574 authored by hujun's avatar hujun

权限判定

parent 6bc1d846
...@@ -10,11 +10,8 @@ namespace app\api_broker\extend; ...@@ -10,11 +10,8 @@ namespace app\api_broker\extend;
* 基类 * 基类
*/ */
use app\model\AAgents; use app\model\AAgents;
use app\model\Users;
use app\model\GOperatingRecords; use app\model\GOperatingRecords;
use Firebase\JWT\JWT;
use think\Controller; use think\Controller;
use think\Db;
use think\Request; use think\Request;
use think\Response; use think\Response;
use Qiniu; use Qiniu;
...@@ -49,11 +46,12 @@ class Basic extends Controller ...@@ -49,11 +46,12 @@ class Basic extends Controller
/** /**
* 基础接口SDK * 基础接口SDK
* @param Request|null $request *
*/
/**
* Basic constructor. * Basic constructor.
* @param Request|null $request * @param Request|null $request
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/ */
public function __construct(Request $request = null) public function __construct(Request $request = null)
{ {
...@@ -82,7 +80,8 @@ class Basic extends Controller ...@@ -82,7 +80,8 @@ class Basic extends Controller
$requestPath = $this->request->routeInfo()["rule"][0] . "/" . $this->request->routeInfo()["rule"][1]; $requestPath = $this->request->routeInfo()["rule"][0] . "/" . $this->request->routeInfo()["rule"][1];
//过滤掉不需要验证token的接口 //过滤掉不需要验证token的接口
if (!in_array(trim($requestPath), $this->filterVerify)) { if (!in_array(trim($requestPath), $this->filterVerify)) {
//$this->tokenVerify(); $this->tokenVerify();
$this->userAuth(trim($requestPath));
} }
unset($this->params["AuthToken"]); unset($this->params["AuthToken"]);
} }
...@@ -264,7 +263,25 @@ class Basic extends Controller ...@@ -264,7 +263,25 @@ class Basic extends Controller
return $result; return $result;
} }
/**
* 权限判定
*
* @param $requestPath
* @return bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function userAuth($requestPath){
$agents = new AAgents();
$is_auth = $agents->agentsAuthId($this->agentId, $requestPath);
if (empty($is_auth['id']) && $this->userId != 1) {
echo json_encode(array( "code" => "300", "msg" => "没有权限!", "data" => [], "type" => "json" ));exit;
}
return true;
}
} }
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