Commit cd91f68d authored by clone's avatar clone

token验证过滤

parent c7a03fb9
......@@ -69,23 +69,30 @@ class Basic extends Controller
$requestPath = $this->request->path();
//过滤掉不需要验证token的接口
if (!in_array(trim($requestPath), $this->filterVerify)) {
if (!isset($this->params['AuthToken'])) {
echo json_encode(array( "code" => "101", "msg" => "AuthToken不能为空!", "data" => [], "type" => "json" ));
exit;
}
$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_;
$this->verifyUserInfo();
$this->verifyTime();
$this->tokenVerify();
}
}
/**
* token 验证
*/
public function tokenVerify(){
if (!isset($this->params['AuthToken'])) {
echo json_encode(array( "code" => "101", "msg" => "AuthToken不能为空!", "data" => [], "type" => "json" ));
exit;
}
$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_;
$this->verifyUserInfo();
$this->verifyTime();
}
public function verifyTime()
{
......
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