fix: Mongoose 8 pre-save hook crash (next->async), v1.0.17 tag, test user

- user.schema.ts: convert pre-save from callback(next) to async - fixes
  'TypeError: next is not a function' on login (Mongoose 8 compat)
- Tag v1.0.17 for 1.0.18 build cycle
- scripts/seed-test-user.ts: utility to create test accounts
- docs: PROJECT-STATUS v4.9, AGENTS.md version bump
- Add test user test@yzrcloud.cn / 123456 (role: user)
This commit is contained in:
yuzhiran
2026-06-22 11:27:21 +08:00
parent 1e8e22c9ed
commit 4d54c8088c
4 changed files with 65 additions and 10 deletions
+2 -3
View File
@@ -69,9 +69,8 @@ export class User {
export const UserSchema = SchemaFactory.createForClass(User)
UserSchema.pre('save', function (next) {
UserSchema.pre('save', async function () {
if (!this.phone && !this.wxOpenid && !this.email) {
return next(new Error('用户必须至少有一个联系方式(手机号/微信/邮箱)'))
throw new Error('用户必须至少有一个联系方式(手机号/微信/邮箱)')
}
next()
})