fix(auth-service): 修复 AlipayProvider TypeScript 类型错误 (unknown 类型断言)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
1fc0fcb95e
commit
e8e2a44fef
|
|
@ -101,17 +101,17 @@ export class AlipayProvider {
|
||||||
code: authCode,
|
code: authCode,
|
||||||
});
|
});
|
||||||
|
|
||||||
const resp = result['alipay_system_oauth_token_response'];
|
const resp = result['alipay_system_oauth_token_response'] as Record<string, unknown> | undefined;
|
||||||
if (!resp || result['error_response']) {
|
if (!resp || result['error_response']) {
|
||||||
const err = result['error_response'] || {};
|
const err = (result['error_response'] || {}) as Record<string, unknown>;
|
||||||
this.logger.error(`Alipay token exchange failed: ${JSON.stringify(err)}`);
|
this.logger.error(`Alipay token exchange failed: ${JSON.stringify(err)}`);
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
`支付宝授权失败: ${err.sub_msg || err.msg || '未知错误'} (code: ${err.code || '?'})`,
|
`支付宝授权失败: ${err['sub_msg'] || err['msg'] || '未知错误'} (code: ${err['code'] || '?'})`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.log(`Alipay token exchanged: userId=${resp.user_id}`);
|
this.logger.log(`Alipay token exchanged: userId=${resp['user_id']}`);
|
||||||
return resp as AlipayTokenResponse;
|
return resp as unknown as AlipayTokenResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -126,16 +126,16 @@ export class AlipayProvider {
|
||||||
accessToken,
|
accessToken,
|
||||||
);
|
);
|
||||||
|
|
||||||
const resp = result['alipay_user_info_share_response'];
|
const resp = result['alipay_user_info_share_response'] as Record<string, unknown> | undefined;
|
||||||
if (!resp || result['error_response'] || resp.code !== '10000') {
|
if (!resp || result['error_response'] || resp['code'] !== '10000') {
|
||||||
const err = result['error_response'] || resp || {};
|
const err = (result['error_response'] || resp || {}) as Record<string, unknown>;
|
||||||
this.logger.error(`Alipay userinfo failed: ${JSON.stringify(err)}`);
|
this.logger.error(`Alipay userinfo failed: ${JSON.stringify(err)}`);
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
`获取支付宝用户信息失败: ${err.sub_msg || err.msg || '请确认已开通「获取会员信息」接口权限'}`,
|
`获取支付宝用户信息失败: ${err['sub_msg'] || err['msg'] || '请确认已开通「获取会员信息」接口权限'}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp as AlipayUserInfo;
|
return resp as unknown as AlipayUserInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue