From c9100d3262827e647d91180759056da5b253992b Mon Sep 17 00:00:00 2001 From: hailin Date: Wed, 4 Mar 2026 03:52:17 -0800 Subject: [PATCH] =?UTF-8?q?fix(auth):=20=E7=A7=BB=E9=99=A4=20wechat.servic?= =?UTF-8?q?e.ts=20=E4=B8=AD=E5=AF=B9=20bcrypt=20=E7=9A=84=E7=9B=B4?= =?UTF-8?q?=E6=8E=A5=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 改用 Password VO 生成随机密码哈希,避免 TypeScript 找不到 bcrypt 类型声明的编译错误。 Co-Authored-By: Claude Sonnet 4.6 --- .../auth-service/src/application/services/wechat.service.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/services/auth-service/src/application/services/wechat.service.ts b/backend/services/auth-service/src/application/services/wechat.service.ts index ed531ab..2bea9de 100644 --- a/backend/services/auth-service/src/application/services/wechat.service.ts +++ b/backend/services/auth-service/src/application/services/wechat.service.ts @@ -31,8 +31,8 @@ import { TokenService } from './token.service'; import { EventPublisherService } from './event-publisher.service'; import { UserRole, UserStatus } from '../../domain/entities/user.entity'; import { AuthResult } from './auth.service'; +import { Password } from '../../domain/value-objects/password.vo'; import * as crypto from 'crypto'; -import * as bcrypt from 'bcrypt'; @Injectable() export class WechatService { @@ -109,7 +109,9 @@ export class WechatService { } // ── 新用户:自动注册 ── - const randomPasswordHash = await bcrypt.hash(crypto.randomBytes(32).toString('hex'), 10); + // 使用 Password VO 生成随机哈希(微信用户无需密码登录) + const randomPw = await Password.create(crypto.randomBytes(32).toString('hex')); + const randomPasswordHash = randomPw.value; const user = await this.userRepo.create({ phone: null,