From c591415e3d3cddf1434d7025da7f9e1a537af2e4 Mon Sep 17 00:00:00 2001 From: Nathaniel Tampus Date: Fri, 11 Aug 2023 20:46:02 +0800 Subject: [PATCH] fix registration for empty email --- server/src/controllers/auth.controller.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/src/controllers/auth.controller.ts b/server/src/controllers/auth.controller.ts index e1f4e37..de7d9cc 100644 --- a/server/src/controllers/auth.controller.ts +++ b/server/src/controllers/auth.controller.ts @@ -107,7 +107,8 @@ export const registerUser = async (req: Request, res: Response) => { return; } - const duplicateUsers = await UserModel.findByNameEmail({ name, email }); + const compareEmail = email || name; + const duplicateUsers = await UserModel.findByNameEmail({ name, email: compareEmail }); if (duplicateUsers && duplicateUsers.length) { const dupl = duplicateUsers[0].name === name ? "Username" : "Email"; res.status(409).json({ message: `${dupl} is already in use.` });