Commit 6671a94e authored by hujun's avatar hujun

token验证

parent 4294e4cb
...@@ -342,4 +342,16 @@ class Broker extends Basic ...@@ -342,4 +342,16 @@ class Broker extends Basic
return $this->response($data['status'], $data['msg'], $data['data']); return $this->response($data['status'], $data['msg'], $data['data']);
} }
/**
* 生成token(临时用)
*
* @return \think\Response
*/
public function token(){
$jwt = new JwtUntils();
$phone = $this->params['phone'];
$token = $jwt->createToken($phone);
return $this->response(200, "", ['AuthToken'=>$token]);
}
} }
\ No newline at end of file
...@@ -13,6 +13,7 @@ use app\model\AAgents; ...@@ -13,6 +13,7 @@ use app\model\AAgents;
use app\model\Users; use app\model\Users;
use app\model\GOperatingRecords; use app\model\GOperatingRecords;
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;
...@@ -37,7 +38,7 @@ class Basic extends Controller ...@@ -37,7 +38,7 @@ class Basic extends Controller
protected $agentPhone; protected $agentPhone;
protected $timeStamp_; protected $timeStamp_;
protected $filterVerify = array( protected $filterVerify = array(
'broker/login' 'broker/token'
); );
/** /**
...@@ -60,21 +61,42 @@ class Basic extends Controller ...@@ -60,21 +61,42 @@ class Basic extends Controller
} elseif (strtoupper($this->request->method()) === "POST") { } elseif (strtoupper($this->request->method()) === "POST") {
$this->params = $this->request->param() != null ? $this->request->param() : null; $this->params = $this->request->param() != null ? $this->request->param() : null;
} }
// if (isset($this->params['AuthToken']) && $this->params['AuthToken'] != 'null' && !empty($this->params['AuthToken'])) { /*临时验证 start*/
// $jwt = new \Firebase\JWT\JWT(); if (isset($this->params['AuthToken']) && $this->params['AuthToken'] != 'null' && !empty($this->params['AuthToken'])) {
// $this->authToken = $this->params['AuthToken']; $jwt = new JWT();
// $result = $jwt->decode($this->authToken, config('jwt_key'), array( 'HS256' )); //解码token $this->authToken = $this->params['AuthToken'];
// $this->agentId = $result->data->id; $result = $jwt->decode($this->authToken, config('jwt_key'), array('HS256')); //解码token
// $this->agentPhone = $result->data->phone; $this->timeStamp_ = $result->timeStamp_;
// $this->agentName = $result->data->userNick; $is = Db::table('agents')->where('phone', $result->data)->count();
// $this->timeStamp_ = $result->timeStamp_;
// } if ($is == 0) {
// echo json_encode(array("code" => "300", "msg" => "用户验证失败,重新登录!", "data" => [], "type" => "json"));
// $requestPath = $this->request->routeInfo()["rule"][0] . "/" . $this->request->routeInfo()["rule"][1]; exit;
// //过滤掉不需要验证token的接口 }
// if (!in_array(trim($requestPath), $this->filterVerify)) { }
// $this->tokenVerify();
// } $requestPath = $this->request->routeInfo()["rule"][0] . "/" . $this->request->routeInfo()["rule"][1];
if (!in_array(trim($requestPath), $this->filterVerify)) {
$this->tokenVerify();
}
/*临时验证 end*/
/* if (isset($this->params['AuthToken']) && $this->params['AuthToken'] != 'null' && !empty($this->params['AuthToken'])) {
$jwt = new \Firebase\JWT\JWT();
$this->authToken = $this->params['AuthToken'];
$result = $jwt->decode($this->authToken, config('jwt_key'), array( 'HS256' )); //解码token
$this->userId = $result->data->id;
$this->phone = $result->data->phone;
$this->userNick = $result->data->userNick;
$this->timeStamp_ = $result->timeStamp_;
}
$requestPath = $this->request->routeInfo()["rule"][0] . "/" . $this->request->routeInfo()["rule"][1];
//过滤掉不需要验证token的接口
if (!in_array(trim($requestPath), $this->filterVerify)) {
$this->tokenVerify();
}*/
} }
......
...@@ -138,7 +138,7 @@ class SecretReport extends Model ...@@ -138,7 +138,7 @@ class SecretReport extends Model
$result = []; $result = [];
foreach ($data as $k => $v) { foreach ($data as $k => $v) {
$result[$k] = $v; $result[$k] = $v;
$result[$k]['price'] = "";
if ($v->agents_id) { if ($v->agents_id) {
$agents_data = Db::table('agents')->field('realName,father_id')->where('id',$v->agents_id)->find(); $agents_data = Db::table('agents')->field('realName,father_id')->where('id',$v->agents_id)->find();
$result[$k]['agents_name'] = $agents_data['realName']; $result[$k]['agents_name'] = $agents_data['realName'];
...@@ -162,8 +162,6 @@ class SecretReport extends Model ...@@ -162,8 +162,6 @@ class SecretReport extends Model
$time += floor($v->time/60); $time += floor($v->time/60);
} }
$result[$k]['price'] = $time*0.06 + $time*0.05;//通话 0.06元/分,录音 0.05元/分 $result[$k]['price'] = $time*0.06 + $time*0.05;//通话 0.06元/分,录音 0.05元/分
} else {
$result[$k]['price'] = "";
} }
} }
......
...@@ -272,6 +272,7 @@ Route::group('broker', [ ...@@ -272,6 +272,7 @@ Route::group('broker', [
'getShopList' => ['api_broker/Shop/getShopList', [ 'method' => 'get|post' ] ], 'getShopList' => ['api_broker/Shop/getShopList', [ 'method' => 'get|post' ] ],
'getShopDetail' => ['api_broker/Shop/getShopDetail', [ 'method' => 'get' ] ], 'getShopDetail' => ['api_broker/Shop/getShopDetail', [ 'method' => 'get' ] ],
'reportList' => ['api_broker/Report/reportList', [ 'method' => 'get' ] ], 'reportList' => ['api_broker/Report/reportList', [ 'method' => 'get' ] ],
'token' => ['api_broker/broker/token', [ 'method' => 'get' ] ],
]); ]);
......
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