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:
@@ -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()
|
||||
})
|
||||
Reference in New Issue
Block a user