duplicate email check
This commit is contained in:
parent
6aa8091774
commit
f07ee52f67
@ -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."
|
||||
|
||||
Loading…
Reference in New Issue
Block a user