From ab2d90d8d2a0efd338c6067323c36cf1bea408b0 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 19 Jan 2026 10:20:49 +0530 Subject: [PATCH] bulk upload existing user fixed --- app/controllers/establishment.controller.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/controllers/establishment.controller.js b/app/controllers/establishment.controller.js index e2f460e..e7c7067 100644 --- a/app/controllers/establishment.controller.js +++ b/app/controllers/establishment.controller.js @@ -1831,6 +1831,15 @@ exports.establishmentBulkUpload = async (req, res) => { const autoPassword = generateSecurePassword(12); const hashed = await bcrypt.hash(autoPassword, 10); + const existingAdminUser = await User.findOne({ where: { email:p.email, is_active: true } }); + if (existingAdminUser) { + logger.warn(`Email already exists in Admin Users: ${p.email}`); + return res.status(409).send({ + status: "failed", + message: "This email address is already registered in the admin users." + }); + } + await EstablishmentUser.create({ establishment_id: est.id, name: r.user_name,