diff --git a/backend/services/auth-service/src/application/services/sms.service.ts b/backend/services/auth-service/src/application/services/sms.service.ts index f8cf1139..4050d868 100644 --- a/backend/services/auth-service/src/application/services/sms.service.ts +++ b/backend/services/auth-service/src/application/services/sms.service.ts @@ -168,11 +168,12 @@ export class SmsService { }); const response = await client.sendSms(request); - if (response.body.code !== 'OK') { - this.logger.error(`阿里云短信发送失败: ${response.body.code} - ${response.body.message}`); + const body = response.body; + if (!body || body.code !== 'OK') { + this.logger.error(`阿里云短信发送失败: ${body?.code} - ${body?.message}`); throw new BadRequestException('短信发送失败,请稍后重试'); } - this.logger.log(`短信发送成功: ${phone}, BizId: ${response.body.bizId}`); + this.logger.log(`短信发送成功: ${phone}, BizId: ${body.bizId}`); } }