From f5406bfe992ad42f3f3d71b077a853c2f1663980 Mon Sep 17 00:00:00 2001 From: undefined Date: Sun, 28 Jan 2024 02:42:49 +0800 Subject: [PATCH] core: fix --- packages/hydrooj/src/model/user.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/hydrooj/src/model/user.ts b/packages/hydrooj/src/model/user.ts index fb734f67f..f15586cc5 100644 --- a/packages/hydrooj/src/model/user.ts +++ b/packages/hydrooj/src/model/user.ts @@ -342,11 +342,14 @@ class UserModel { } catch (e) { if (e?.code === 11000) { // Duplicate Key Error + if (autoAlloc && JSON.stringify(e.keyPattern) === '{"_id":1}') { + uid++; + continue; + } throw new UserAlreadyExistError(Object.values(e?.keyValue || {})); } - if (!autoAlloc || JSON.stringify(e.keyPattern) !== '{"_id":1}') throw e; + throw e; } - uid++; } }