From 2662409d807618d43f54507cc3f81263ab05d917 Mon Sep 17 00:00:00 2001 From: hailin Date: Fri, 19 Dec 2025 03:20:37 -0800 Subject: [PATCH] =?UTF-8?q?fix(identity-service):=20=E4=BF=AE=E5=A4=8D=20T?= =?UTF-8?q?ypeScript=20=E7=BC=96=E8=AF=91=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复 account.id -> account.userId 属性访问错误 - 修复 smsService.verifySmsCode 方法调用,改为直接从 Redis 验证 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../services/user-application.service.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/backend/services/identity-service/src/application/services/user-application.service.ts b/backend/services/identity-service/src/application/services/user-application.service.ts index 60e4b06a..1c417bec 100644 --- a/backend/services/identity-service/src/application/services/user-application.service.ts +++ b/backend/services/identity-service/src/application/services/user-application.service.ts @@ -483,7 +483,7 @@ export class UserApplicationService { // 发布用户资料更新事件 const event = new UserProfileUpdatedEvent({ - userId: account.id.value.toString(), + userId: account.userId.toString(), accountSequence: account.accountSequence.value, nickname: account.nickname, avatarUrl: account.avatarUrl, @@ -1296,17 +1296,17 @@ export class UserApplicationService { const phoneNumber = PhoneNumber.create(command.phoneNumber); - // 验证验证码 - const isValid = await this.smsService.verifySmsCode( - phoneNumber.value, - command.smsCode, - command.type, - ); + // 从 Redis 获取验证码进行验证 + const cacheKey = `sms:${command.type.toLowerCase()}:${phoneNumber.value}`; + const cachedCode = await this.redisService.get(cacheKey); - if (!isValid) { + if (!cachedCode || cachedCode !== command.smsCode) { throw new ApplicationError('验证码错误或已过期'); } + // 验证成功后删除验证码 + await this.redisService.delete(cacheKey); + this.logger.log(`SMS code verified successfully for phone: ${this.maskPhoneNumber(command.phoneNumber)}`); }