1.远程验证token有效性
This commit is contained in:
@@ -466,8 +466,20 @@ class Playx extends Api
|
||||
$code = $res->getStatusCode();
|
||||
$data = json_decode(strval($res->getBody()), true);
|
||||
if ($code !== 200 || empty($data['user_id'])) {
|
||||
$remoteMsg = $data['message'] ?? '';
|
||||
$msg = is_string($remoteMsg) && $remoteMsg !== '' ? $remoteMsg : __('Token expiration');
|
||||
$remoteMsg = '';
|
||||
if (is_array($data)) {
|
||||
$candidateMsg = $data['message'] ?? ($data['msg'] ?? ($data['error'] ?? ''));
|
||||
if (is_string($candidateMsg) && $candidateMsg !== '') {
|
||||
$remoteMsg = $candidateMsg;
|
||||
}
|
||||
}
|
||||
if ($remoteMsg === '') {
|
||||
$bodyText = strval($res->getBody());
|
||||
if ($bodyText !== '') {
|
||||
$remoteMsg = mb_substr($bodyText, 0, 300);
|
||||
}
|
||||
}
|
||||
$msg = $remoteMsg !== '' ? $remoteMsg : __('Token expiration');
|
||||
|
||||
return $this->error($msg, null, 0, ['statusCode' => 401]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user