|
|
|
@ -29,6 +29,35 @@ class CorsMiddleware implements MiddlewareInterface |
|
|
|
return $response; |
|
|
|
} |
|
|
|
|
|
|
|
$request = \Hyperf\Utils\Context::override(ServerRequestInterface::class, function (ServerRequestInterface $request) |
|
|
|
{ |
|
|
|
$preDatas = $request->getParsedBody(); |
|
|
|
if(isset($preDatas['market_id'])){ |
|
|
|
if($preDatas['market_id']==-1){ |
|
|
|
$preDatas['market_id'] = 0; |
|
|
|
|
|
|
|
if (env('APP_ENV') == 'prod') { |
|
|
|
unset($preDatas['sign']); |
|
|
|
$sign = $this->signature($preDatas); |
|
|
|
$preDatas['sign'] = $sign; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return $request->withParsedBody($preDatas); |
|
|
|
}); |
|
|
|
|
|
|
|
return $handler->handle($request); |
|
|
|
} |
|
|
|
|
|
|
|
private function signature($params) |
|
|
|
{ |
|
|
|
ksort($params); |
|
|
|
|
|
|
|
$http_query = []; |
|
|
|
foreach ($params as $key => $value) { |
|
|
|
$http_query[] = $key.'='.$value; |
|
|
|
} |
|
|
|
|
|
|
|
return sha1(md5(implode('&', $http_query)).config('auth.api.sign.secret_key')); |
|
|
|
} |
|
|
|
} |