优化每日推送接口/api/v1/playx/daily-push
This commit is contained in:
@@ -14,7 +14,6 @@ use app\common\model\MallPlayxDailyPush;
|
||||
use app\common\model\MallPlayxSession;
|
||||
use app\common\model\MallPlayxOrder;
|
||||
use app\common\model\MallPlayxUserAsset;
|
||||
use app\common\library\PlayxInboundJwt;
|
||||
use support\think\Db;
|
||||
use Webman\Http\Request;
|
||||
use support\Response;
|
||||
@@ -157,14 +156,6 @@ class Playx extends Api
|
||||
return $response;
|
||||
}
|
||||
|
||||
$partnerJwtSecret = strval(config('playx.partner_jwt_secret', ''));
|
||||
if ($partnerJwtSecret !== '') {
|
||||
$authHeader = strval($request->header('authorization', ''));
|
||||
if (!PlayxInboundJwt::verifyBearer($authHeader, $partnerJwtSecret)) {
|
||||
return $this->error(__('Invalid or missing JWT'), null, 0, ['statusCode' => 401]);
|
||||
}
|
||||
}
|
||||
|
||||
$body = $request->post();
|
||||
if (empty($body)) {
|
||||
$raw = $request->rawBody();
|
||||
@@ -179,12 +170,12 @@ class Playx extends Api
|
||||
$ts = $request->header('X-Timestamp', '');
|
||||
$rid = $request->header('X-Request-Id', '');
|
||||
if ($sig === '' || $ts === '' || $rid === '') {
|
||||
return $this->error(__('Invalid signature'), null, 0, ['statusCode' => 401]);
|
||||
return $this->error(__('Daily push signature missing or incomplete'), null, 0, ['statusCode' => 401]);
|
||||
}
|
||||
$canonical = $ts . "\n" . $rid . "\nPOST\n/api/v1/playx/daily-push\n" . hash('sha256', json_encode($body));
|
||||
$expected = hash_hmac('sha256', $canonical, $secret);
|
||||
if (!hash_equals($expected, $sig)) {
|
||||
return $this->error(__('Invalid signature'), null, 0, ['statusCode' => 401]);
|
||||
return $this->error(__('Daily push signature verification failed'), null, 0, ['statusCode' => 401]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,7 +250,7 @@ class Playx extends Api
|
||||
|
||||
$asset = $this->ensureAssetForPlayx($playxUserId, $username);
|
||||
if (!$asset) {
|
||||
throw new \RuntimeException(__('Failed to map playx user to mall user'));
|
||||
throw new \RuntimeException(__('Failed to ensure PlayX user asset'));
|
||||
}
|
||||
|
||||
if ($asset->today_limit_date !== $date) {
|
||||
@@ -345,7 +336,7 @@ class Playx extends Api
|
||||
|
||||
$asset = $this->ensureAssetForPlayx($playxUserId, strval($body['username'] ?? ''));
|
||||
if (!$asset) {
|
||||
throw new \RuntimeException(__('Failed to map playx user to mall user'));
|
||||
throw new \RuntimeException(__('Failed to ensure PlayX user asset'));
|
||||
}
|
||||
|
||||
if ($asset->today_limit_date !== $date) {
|
||||
|
||||
Reference in New Issue
Block a user