fix(auth): 修复设置支付密码时报错的问题

支付密码是6位纯数字,但 setTradePassword 调用了 Password.create()
走了登录密码的格式验证(要求≥8位+字母+数字),导致必然抛出异常。

新增 Password.createWithoutValidation() 方法,仅做 bcrypt hash
不走格式验证。支付密码的格式验证由 trade-password.service.ts 独立处理。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-02-26 09:01:33 -08:00
parent 4a1bf3aafe
commit 16da1d20f0
2 changed files with 10 additions and 2 deletions

View File

@ -251,10 +251,10 @@ export class UserAggregate {
}
/**
*
* 6使
*/
async setTradePassword(newPlainPassword: string): Promise<void> {
const password = await Password.create(newPlainPassword);
const password = await Password.createWithoutValidation(newPlainPassword);
this._tradePasswordHash = password.hash;
this._updatedAt = new Date();
}

View File

@ -20,6 +20,14 @@ export class Password {
return new Password(hash);
}
/**
*
*/
static async createWithoutValidation(plainPassword: string): Promise<Password> {
const hash = await bcrypt.hash(plainPassword, Password.SALT_ROUNDS);
return new Password(hash);
}
/**
* hash
*/