duplicate email check

This commit is contained in:
unknown 2026-01-20 12:08:00 +05:30
parent 6aa8091774
commit f07ee52f67

View File

@ -40,6 +40,7 @@ exports.createUser = async (req, res) => {
const existingUser = await EstablishmentUser.findOne({
where: { email, is_active: true }
});
const checkEmailInAdminUser = await User.findOne({ where: { email, is_active: true } });
if (existingUser) {
return res.status(409).json({
@ -48,9 +49,8 @@ exports.createUser = async (req, res) => {
});
}
const existingAdminUser = await User.findOne({ where: { email, is_active: true } });
if (existingAdminUser) {
logger.warn(`Email already exists in Admin Users: ${email}`);
if (checkEmailInAdminUser) {
logger.info(`Email already exists in Admin Users: ${email}`);
return res.status(409).send({
status: "failed",
message: "This email address is already registered in the admin users."