From 41a1a7ae6685b1785b4064bd3c3c340c3bb478c9 Mon Sep 17 00:00:00 2001 From: undefined Date: Wed, 19 Apr 2023 18:18:51 +0800 Subject: [PATCH] core: userimport: also check duplicate in pending list (#559) --- packages/hydrooj/src/handler/manage.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/hydrooj/src/handler/manage.ts b/packages/hydrooj/src/handler/manage.ts index cfa7cdba4..c08b0a62b 100644 --- a/packages/hydrooj/src/handler/manage.ts +++ b/packages/hydrooj/src/handler/manage.ts @@ -232,9 +232,9 @@ class SystemUserImportHandler extends SystemHandler { if (!Types.Email[1](email)) messages.push(`Line ${+i + 1}: Invalid email.`); else if (!Types.Username[1](username)) messages.push(`Line ${+i + 1}: Invalid username`); else if (!Types.Password[1](password)) messages.push(`Line ${+i + 1}: Invalid password`); - else if (await user.getByEmail('system', email)) { + else if (udocs.find((t) => t.email === email) || await user.getByEmail('system', email)) { messages.push(`Line ${+i + 1}: Email ${email} already exists.`); - } else if (await user.getByUname('system', username)) { + } else if (udocs.find((t) => t.username === username) || await user.getByUname('system', username)) { messages.push(`Line ${+i + 1}: Username ${username} already exists.`); } else { const payload: any = {};